Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble getting Android Support V7 CardView Library to work

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?

like image 468
John61590 Avatar asked Nov 09 '14 08:11

John61590


2 Answers

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.

like image 167
Sakamiai Avatar answered Oct 19 '22 02:10

Sakamiai


Hi this might be helpful, this worked for me. (for intellij users)

  • click in your project,
  • right click -> open Module Settings (f4)
  • import cardview from \sdk\extras\android\support\v7\
  • add .jar file to cardview module
  • click on your project and give module dependency to cardview
  • now, click (+) button on cardview -> android -> at top you will see a check box (library module), enable it.
  • click ok and close your settings dialog.
  • rebuild your project and run it.
like image 37
SureshCS50 Avatar answered Oct 19 '22 02:10

SureshCS50