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.0’ in your dependencies
Have your Application class extend MultiDexApplication instead of just Application. Alternatively, you can call MultiDex.install() in attachBaseContext() of your application.
See https://developer.android.com/tools/building/multidex.html for more details.

Minimal MultiDex capable application. To use the legacy multidex library there is 3 possibility:

Declare this class as the application in your AndroidManifest.xml. Have your Application extends this class. Have your Application override attachBaseContext starting with protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);

你可能感兴趣的:(android,multidex,NoClassDef)