Error inflating class and android.support.v7.widget.CardView

后端 未结 15 1635
-上瘾入骨i
-上瘾入骨i 2020-11-27 20:47

I want to use CardView in my project, but when I run my application, I get the following error. I\'m using Eclipse.

Error: Error inflating clas         


        
15条回答
  •  伪装坚强ぢ
    2020-11-27 21:41

    @sunil

    As said before:

    1. Go to File -> Import -> Existing Android code into workspace --> Browse (Go to sdk/extras/android/support/v7/cardview) --> Click ok --> Click Finish

    2. Right click on cardview project --> Properties --> Android(Left Pane) --> Enable isLibrary (tick the checkbox) --> Apply --> ok

    3. Right click on your project --> Properties --> Android(Left pane) --> Add (under library) --> cardview --> apply --> ok

    If this doesn't work, proceed to add and remove individual jar's of the same package from your now imported code's library project's folder android-support-v7-cardview/libs. Remove the Jar, clean the project and try it again. Remove the project one bloke suggested adding, remove any external Jar's related to cardview (I think these cause conflicts). Clean the project and hopefully that works for you.

    Note: I personally did have to change the cardview library's target build level from 4.0.3 to 5.0 then back to 4.1.2, cleaning the project each time, for it to work as well.

提交回复
热议问题