ClassNotFoundException: "com.google.android.material.card.MaterialCardView"
See original GitHub issueOverview
Trying to use com.google.android.material.card.MaterialCardView on my project. I’ve set my design/support dependencies to 28.0.0-alpha1 and set compileSdkVersion ‘android-P’. I’m also setting Theme.MaterialComponents.Light.NoActionBar as my parent app theme. I get ClassNotFoundExceptions when I try to use any of the material widgets, including MaterialCardView.
Here is the stack trace:
05-27 00:41:55.189 8022-8022/com.miser.billmoney E/AndroidRuntime: FATAL EXCEPTION: main Process: com.miser.billmoney, PID: 8022 android.view.InflateException: Binary XML file line #159: Binary XML file line #159: Error inflating class com.google.android.material.card.MaterialCardView Caused by: android.view.InflateException: Binary XML file line #159: Error inflating class com.google.android.material.card.MaterialCardView Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.material.card.MaterialCardView" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.miser.billmoney-82jv4GAw3oNM4puzAMQEgg==/base.apk"],nativeLibraryDirectories=[/data/app/com.miser.billmoney-82jv4GAw3oNM4puzAMQEgg==/lib/x86, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.view.LayoutInflater.createView(LayoutInflater.java:606) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at com.miser.billmoney.fragments.HomeFragment.onCreateView(HomeFragment.kt:70) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2335) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1423) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1754) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1822) at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3239) at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3195) at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:195) at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:596) at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1382) at android.app.Activity.performStart(Activity.java:7151) at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2949) at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:194) at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:180) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:157) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:72) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1800) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6649) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)
Version number
- 28.0.0-alpha1
Operating system and device
Android P - Pixel 2xl
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
just add android:theme=“@style/Theme.MaterialComponents.Light” to com.google.android.material.card.MaterialCardView in xml and all will be fine
example: <com.google.android.material.card.MaterialCardView android:id=“@+id/subSectionsCardView” android:layout_width=“match_parent” android:layout_height=“match_parent” android:theme=“@style/Theme.MaterialComponents.Light” … etc
You can use Material Components with 28.0.0-alpha1, the only difference is the package name. If using
com.android.support:design:28.0.0-alpha1
, you have to useandroid.support.design.*
for all of the widgets. If usingcom.google.android.material:material:1.0.0-alpha1
, you have to usecom.google.android.material.*
.