What is the correct way of using multidex for < 5 devices?

leo-mckleo-mck BRMember ✭✭

I have an app that used to work fine. Then, it started to give the "java exited with code 2" error. Checked "multidex", now it builds but does not run on devices/emulator with version < 5. The error I get when I try to run the app is:

E/AndroidRuntime( 5197): FATAL EXCEPTION: main
E/AndroidRuntime( 5197): java.lang.RuntimeException: Unable to instantiate application md5ca9dc7995573f88fa252bb637ad878c4.MainApplication: java.lang.ClassNotFoundException: md5ca9dc7995573f88fa252bb637ad878c4.MainApplication
E/AndroidRuntime( 5197):        at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
E/AndroidRuntime( 5197):        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4124)
E/AndroidRuntime( 5197):        at android.app.ActivityThread.access$1300(ActivityThread.java:130)
E/AndroidRuntime( 5197):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
E/AndroidRuntime( 5197):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 5197):        at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 5197):        at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime( 5197):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5197):        at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 5197):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 5197):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 5197):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5197): Caused by: java.lang.ClassNotFoundException: md5ca9dc7995573f88fa252bb637ad878c4.MainApplication
E/AndroidRuntime( 5197):        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime( 5197):        at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime( 5197):        at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime( 5197):        at android.app.Instrumentation.newApplication(Instrumentation.java:967)
E/AndroidRuntime( 5197):        at android.app.LoadedApk.makeApplication(LoadedApk.java:496)
E/AndroidRuntime( 5197):        ... 11 more

I have a custom Application (MainApplication) that inherit from Application. I tried some things I found here and other sites but nothing worked. Can someone at xamarin please list what is the steps to make this work? My app is already more than a year on the store, I have an update pending because of this problem. Please help.

I am using:

Xamarin 4.6.0.299 (b63523e27)
Xamarin.Android SDK 7.4.0.21 (2851083)
Xamarin.iOS and Xamarin.Mac SDK 10.12.0.20 (80b8487)

Answers

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    edited September 2017

    Bugzilla cross-reference

    One likely cause of the issue with Xamarin.Android 7.4 is:

    As mentioned in that bug, one way to work around that issue temporarily is to copy the generated multidex.keep file into your project folder, add the missing newlines, and add it to your project with a build action of MultiDexMainDexList.

Sign In or Register to comment.