Skip to content Skip to sidebar Skip to footer

Android Studio Cardview Error: Could Not Be Instantiated

I get this error whenever I put a CardView in my activity_main.xml. The following classes could not be instantiated: - android.support.v7.widget.CardView (Open Class, Show Excepti

Solution 1:

Try using same version of your appcompat-v7.

compile'com.android.support:cardview-v7:23.2.1'compile'com.android.support:recyclerview-v7:23.2.1'

Solution 2:

Add appcompat version.

com.android.support:appcompat-v7:25.0.0

And also add if you haven't added design support.

com.android.support:design:25.0.0

Solution 3:

I found the problem. The theme was not compatible. I started a new project with the default theme and just added this to the build.gradle.

compile'com.android.support:design:23.2.1'compile'com.android.support:cardview-v7:23.2.1' //CardView
    compile'com.android.support:recyclerview-v7:23.2.1'//RecyclerView

After that I just added the CardView in Design Mode and it worked, no errors.

Solution 4:

In case its about missing styles add style="@style/CardView" to your CardView.

Post a Comment for "Android Studio Cardview Error: Could Not Be Instantiated"