MultiDex NoClassDefFound error

Your AppWrapper class fails to load because the retrofit.ErrorHandler interface is not included in main dex file.

How do you calculate which classes to put in your main-dex-list file?
There's a script that can generate it for you. I wrote a blogpost that shows how to use it.

Update (10/31/2014):
Gradle plugin v0.14.0 now does it automatically. See my answer here.

Update (24/04/2017):
The developer guide explains how to pick specific classes with a gradle option if it doesn't pick all the right ones automatically.


if everything looks OK, but this error appears,

try to disable instant run!!!

when I disabled it all the classes were loaded properly.


If you're extending the MultiDexApplication you don't need to make the MultiDex.install(context) call as it's already happening (see source link). If you need to use attachBaseContext then just make sure to call super.attachBaseContext(context).

https://android.googlesource.com/platform/frameworks/multidex/+/1bb1ab007f6b9405227ea4ce07d2061e4dbb6fe0/library/src/android/support/multidex/MultiDexApplication.java

We just updated developers.android.com with instructions on how to use the support library with the Android gradle plugin including an development optimization for quick development build cycle times.

https://developer.android.com/tools/building/multidex.html

Tags:

Java

Android