Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

MultiDex in Release Mode

VladislavKasianenkoVladislavKasianenko UAMember ✭✭
edited June 2017 in Xamarin.Forms

Hello.
I have an issue with launching my app in Release mode.

Looks like I have reached my limit of 65k references, so I have enabled MultiDex for Debug and Release modes. When deploying in Debug mode, my app is working fine and everything OK. But when I launch it Release mode, it crashes at stratup. Here's a Device Log

Time    Device Name Type    PID Tag Message
06-25 13:36:02.311   4.5" KitKat (4.4) HDPI Phone   Error   7043    AndroidRuntime  java.lang.RuntimeException: Unable to instantiate application android.support.multidex.MultiDexApplication: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/com.kasianeko.myapp1-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.kasianeko.myapp1-1, /system/lib]]
    at android.app.LoadedApk.makeApplication(LoadedApk.java:507)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4301)
    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    at dalvik.system.NativeStart.main(Native Method)
06-25 13:36:03.563   4.5" KitKat (4.4) HDPI Phone   Warning 690 EGL_emulation   eglSurfaceAttrib not implemented
06-25 13:36:03.335   4.5" KitKat (4.4) HDPI Phone   Warning 461 ActivityManager Activity pause timeout for ActivityRecord{b32e4288 u0 com.kasianeko.myapp1/md5304a4440170d60bf491ab72e27e31f91.MainActivity t21 f}
06-25 13:36:02.311   4.5" KitKat (4.4) HDPI Phone   Error   7043    AndroidRuntime  Process: com.kasianeko.my-app1, PID: 7043
06-25 13:36:02.311   4.5" KitKat (4.4) HDPI Phone   Error   7043    AndroidRuntime  FATAL EXCEPTION: main
06-25 13:36:02.311   4.5" KitKat (4.4) HDPI Phone   Error   7043    AndroidRuntime  Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/com.kasianeko.myapp1-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.kasianeko.myapp1-1, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    at android.app.Instrumentation.newApplication(Instrumentation.java:975)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:502)
    ... 11 more
  Force finishing activity com.kasianeko.myapp1/md5304a4440170d60bf491ab72e27e31f91.MainActivity
06-25 13:36:02.307   4.5" KitKat (4.4) HDPI Phone   Debug   7043    AndroidRuntime  Shutting down VM
06-25 13:36:02.307   4.5" KitKat (4.4) HDPI Phone   Warning 7043    dalvikvm    threadid=1: thread exiting with uncaught exception (group=0xb2c92b20)

I tried to add some lines into multidex.keep:

        android/support/multidex/ZipUtil.class
        android/support/multidex/ZipUtil$CentralDirectory.class
        android/support/multidex/MultiDex$V14.class
        android/support/multidex/MultiDexExtractor$1.class
        android/support/multidex/MultiDexExtractor.class
        android/support/multidex/MultiDexApplication.class
        android/support/multidex/MultiDex.class
        android/support/multidex/MultiDex$V19.class
        android/support/multidex/MultiDex$V4.class
        mono/MonoRuntimeProvider.class
        mono/MonoPackageManager.class
        mono/MonoPackageManager_Resources.class
        mono/android/Seppuku.class
        mono/android/app/ApplicationRegistration.class
        mono/android/app/NotifyTimeZoneChanges.class
        md5b3cec4ec1831c6a7ac763d1a35a98e61/MyApp1GcmListenerService.class
        md5b3cec4ec1831c6a7ac763d1a35a98e61/MyApp1InstanceIDListenerService.class
        md5b3cec4ec1831c6a7ac763d1a35a98e61/RegistrationIntentService.class

No luck.

Another thing I found out is: in obj/Debug/android/big I have classes.dex and classes2.dex, but in obj/Release/android/bin/ I have only classes.dex.

I have also specified Android Build SDK to 25.0.3, and the minimum API level is 19 (to support KitKat 4.4.2). ProGuard specified for Release mode.
In AndroidManifest I specified this:

<application android:name="android.support.multidex.MultiDexApplication">
</application>

So, I have no any ideas what's going on with Android. Looks very weird for Windows dev.

Answers

Sign In or Register to comment.