I wanted to try out the new toys that google gave us and I\'ve run into some trouble.
Here is my build.gradle:
apply plugin: \'com.android.applicatio
try adding this line to your RelativeLayout
xmlns:card_view="http://schemas.android.com/apk/res-auto"
I was able to get this to work by adding the following to my build.gradle: compile 'com.android.support:cardview-v7:21.+'
Hope this helps.
This is a bug in Android Studio, see https://code.google.com/p/android/issues/detail?id=79071
One of the comments of the patch reads: "This was causing card view rendering to fail. CardView declared styles of the form CardView.Dark due to which the generated R class failed to load."
Next version should have this fixed according to the bug report (the patch is on branch studio-1.0-dev). They say to build the project once as a workaround, but this does not fix it for me (even though I have exactly the same error and stack trace).
Go to app, right click on: Open module -> Settings -> Dependencies.
Go to "Declared dependencies" and you will find the "+" sign under the title.
Click on "Library dependencies".
Search for "Material" and go to "version section".
Apply 1.0.0 and click "ok".
And then search for card view you will get it on and the class
It solved me by adding xmlns:card_view="http://schemas.android.com/apk/res-auto"
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:card_view="http://schemas.android.com/apk/res-auto"> --->> ******
....
...
<android.support.v7.widget.CardView>
..
...
.....
</android.support.v7.widget.CardView>
</LinearLayout>
I was able to get it to work on the emulator by changing my build.gradle to this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:cardview-v7:+'
}
Make sure you have the support repository installed from the SDK Manager! Hope this helps
EDIT: as someone suggested using 'com.android.support:cardview-v7:23.1' is a better practice but it not required.