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
In my case i have to do both the things add android.support.v7.widget.CardView
as a library project and also add + check it's jar file in java build path
Go to File -> Import -> Existing Android code into workspace --> Browse (Go to sdk/extras/android/support/v7/cardview) --> Click ok --> Click Finish
Right click on cardview project --> Properties --> Android(Left Pane) --> Enable isLibrary (tick the checkbox) --> Apply --> ok
Right click on your project --> Properties --> Android(Left pane) --> Add (under library) --> cardview --> apply --> ok
right click on your project again --> build path --> configure build path -->under libraries-->add jar-->expand cardview-->expand libs-->select android.support.v7.widget.CardView.jar
under order and export-->check android.support.v7.widget.CardView.jar
-->click ok
@sunil
As said before:
Go to File -> Import -> Existing Android code into workspace --> Browse (Go to sdk/extras/android/support/v7/cardview) --> Click ok --> Click Finish
Right click on cardview project --> Properties --> Android(Left Pane) --> Enable isLibrary (tick the checkbox) --> Apply --> ok
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.
I wasted hours on this, for me the final piece of the puzzle was going to the "cardview" project that had been imported into Eclipse as an Android project, then right clicking > properties > android > and changing it from Android 2.1 to Lollipop!