Crash: Java.lang.NoClassDefFoundError: Android.support.v7.appcompat.R$layout
Solution 1:
I know that issue was solved but if you arrive on this thread, it could be that it doesn't solve your problem in one particular combination:
- All works on 5.0 devices
- It doesn't work on 4.x
- You think you enable MultiDex
- Proguard doesn't seem to be a problem
It happened to me and I searched for 3 hours. I hope it'll help some.
To enable MultiDex on 4.x devices, it is not enough to modify the build: you have to subclass the Application
class. Just follow that and that
Hope it helps.
Solution 2:
I fixed the issue by using Proguard with the following config:
-keep class !android.support.v7.internal.view.menu.**,** {*;}
-dontwarn
-ignorewarnings
-dontshrink
To enable Proguard with newer versions of Gradle (in Android Studio):
android {
...
buildTypes {
debug {
...
}
release {
...
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
proguard-rules.pro is where the properties at the top go.
Solution 3:
If you use multidex in your application, extend your Application class from MultiDexApplication
Solution 4:
if you're using api compat support-v7, any libraries whose reference to it should be marked exclude module: 'support-v4'
for example:
compile('com.android.support:cardview-v7:22.2.0') { exclude module: 'support-v4' }
Post a Comment for "Crash: Java.lang.NoClassDefFoundError: Android.support.v7.appcompat.R$layout"