NoClassDefFoundError with Android Studio on Android 4
I was incompletely implementing MultiDex support, so some of my classes weren't in the proper dex file. To fix it, you have to do more than just set multiDexEnabled = true
in your defaultConfig
block. You also have to:
- Include
compile 'com.android.support:multidex:1.0.1'
in your dependencies - Have your Application class extend
MultiDexApplication
instead of justApplication
. Alternatively, you can callMultiDex.install()
inattachBaseContext()
of your application.
See https://developer.android.com/tools/building/multidex.html for more details.
1) Add multiDexEnabled = true
in your default Config
2) Add compile com.android.support:multidex:1.0.0
in your dependencies
3) Application
class extend MultiDexApplication
instead of just Application
1) add multiDexEnabled = true in your defaultConfig in build.gradle.
2) You also have to Include compile 'com.android.support:multidex:1.0.1'
3) add the following to your "application" tag in your manifest:
android:name="android.support.multidex.MultiDexApplication"
its working with me , hope that help