I have an app that is too big to fit into one dex file so I'm using multidex. It works fine when i create it on certain machines, but when i create it on another one, the app crashes on some devices, not all (crashes on Note 2, works on Nextus 6).
8519-8519/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.multidex.MultiDexExtractor
at android.support.multidex.MultiDex.install(MultiDex.java:159)
at com.myapp.MyApplication.onCreate(MyApplication.java:39)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4228)
at android.app.ActivityThread.access$1300(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1287)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
at dalvik.system.NativeStart.main(Native Method)
I decompiled the APK, and found that the MultiDexExtractor class is in classes2.dex instead of classes.dex where it should be.
I thought gradle v1.0.0 and above is placing all the classes in the correct dex automatically? Any ideas?
In the gradle file, i've added
compile 'com.android.support:multidex:1.0.0'
in the dependencies and
multiDexEnabled true
in the default config
Then in the Application file:
@Override
public void onCreate() {
MultiDex.install(this);
super.onCreate();
}
I'm using the android build tools 22.0.1
And here are my gradle versions:
$ ./gradlew --version
------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------
Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_25 (Oracle Corporation 25.25-b02)
OS: Mac OS X 10.9.5 x86_64