Reputation: 1106
I'm using IntelliJ/Android Studio with Ant build (not Gradle at the moment), and am trying to use android-support-v7-cardview.jar but I continue to get
android.view.InflateException: Binary XML file line #19: Error inflating class android.support.v7.widget.CardView
java.lang.NoClassDefFoundError: android.support.v7.cardview.R$styleable
I am not using m2repository with the aar file, but am using the cardview at location
sdk/extras/android/support/v7
I have gotten it to work by using the classes from the jar in my own project, but it requires API 21 (5.0) which I don't want to use yet. I am trying to use the jar file in the libs folder and res files from
sdk/extras/android/support/v7/cardview/res
I have added the lib file and res files to my own project, but still get the error messages above. What should I do?
Upvotes: 7
Views: 7542
Reputation: 405
I had the exact same problem after adding compile 'com.android.support:cardview-v7:23.2.1'
to build.gradle's dependencies to use the CardView, however after cleaning the project (Build > Clean Project) everything worked like magic.
Upvotes: 14
Reputation: 1807
If you are using Android Studio then its quick easier, Please add compile 'com.android.support:cardview-v7:21.+' in dependencies in build.gradle.
dependencies {
compile 'com.android.support:cardview-v7:21.+'
}
Upvotes: 0
Reputation: 3768
Hi this might be helpful, this worked for me. (for intellij users)
Upvotes: 2
Reputation: 1106
I didn't figure out the error really but I just commented out the stuff that uses Android 5.0 in the source code of the library and it works fine. I didn't want to use a minSdk of Android 5.0.
Upvotes: 0
Reputation: 13283
I think you have to import it as an Android library project, then the ressources should be found correctly. I also tried first to import only the jar which didn't work, so I did it this way:
That should do it
Upvotes: 0