Bug 40361 - Multidex crash on devices < Android 5.0 in Release mode
Summary: Multidex crash on devices < Android 5.0 in Release mode
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 6.0.1 (C6SR1)
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2016-04-13 19:42 UTC by Peter Collins
Modified: 2016-05-26 21:05 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Here is release msbuild output! (3.91 MB, text/plain)
2016-04-14 03:05 UTC, klark
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Peter Collins 2016-04-13 19:42:00 UTC
Today, I switch beta channel , Update to Xamarin 4.1.0.33 and Xamarin Studio 6.0.0 version!
In the debug mode,my app can run without any problems below android 5.0(andorid 4.4.4),
but in the release mode,my app get the running crashed information:

[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: AnXinMe.RemoteTv.Droid, PID: 15164
[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/AnXinMe.RemoteTv.Droid-1.apk"],nativeLibraryDirectories=[/data/app-lib/AnXinMe.RemoteTv.Droid-1, /vendor/lib, /system/lib]]
[AndroidRuntime] at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
[AndroidRuntime] at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4427)
[AndroidRuntime] at android.app.ActivityThread.access$1500(ActivityThread.java:147)
[AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:102)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:136)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:5135)
[AndroidRuntime] at java.lang.reflect.Method.invokeNative(Native Method)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Method.java:515)
[AndroidRuntime] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
[AndroidRuntime] at dalvik.system.NativeStart.main(Native Method)
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/AnXinMe.RemoteTv.Droid-1.apk"],nativeLibraryDirectories=[/data/app-lib/AnXinMe.RemoteTv.Droid-1, /vendor/lib, /system/lib]]
[AndroidRuntime] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
[AndroidRuntime] at android.app.Instrumentation.newApplication(Instrumentation.java:975)
[AndroidRuntime] at android.app.LoadedApk.makeApplication(LoadedApk.java:504)
[AndroidRuntime] ... 11 more
[Process] Sending signal. PID: 15164 SIG: 9

At obj\Debug\android\bin directory exits two class files: classes.dex classes2.dex;
Instead,at obj\Release\android\bin directory exits one class file:classes.dex;
Is release mode msbuild bug?
In the end,I add  multidex.keep file into my project:

android/support/multidex/MultiDexApplication.class
android/support/multidex/MultiDex.class
android/support/multidex/MultiDexExtractor$1.class
android/support/multidex/MultiDexExtractor.class
android/support/multidex/MultiDex$V14.class
android/support/multidex/MultiDex$V19.class
android/support/multidex/MultiDex$V4.class
android/support/multidex/ZipUtil$CentralDirectory.class
android/support/multidex/ZipUtil.class

select build action "MultiDexMainDexList".

Clean all->Rebuild all..

But, still crashed at startup running time!
Comment 1 Peter Collins 2016-04-13 19:44:02 UTC
If at all possible, please provide some sample code which reproduces this issue.

Also, providing diagnostic msbuild build output would be very beneficial in attempting to diagnose this.

https://developer.xamarin.com/guides/android/troubleshooting/troubleshooting/#Diagnostic_MSBuild_Output
Comment 2 klark 2016-04-14 03:05:07 UTC
Created attachment 15716 [details]
Here is  release msbuild output!

Here is  release msbuild output!
Comment 3 Peter Collins 2016-04-14 16:45:33 UTC
@Atsushi can you glean anything from the output above that may suggest a cause for the behavior described?
Comment 5 klark 2016-04-21 07:04:38 UTC
@Peter Collins   
How long does it take to fix this BUG?
Thanks!
Comment 6 Atsushi Eno 2016-04-21 08:41:54 UTC
Unassigning until there is reproducible proof for development team.
Comment 7 Peter Collins 2016-04-21 14:37:38 UTC
@klark any chance you could provide some sample code which will reproduce the problem?
Comment 8 klark 2016-04-24 02:04:06 UTC
@Peter Collins
Recently,I find that my app worked good in debug mode and release mode in all devices when i active multidex option only.When i active proguard in release mode,my project buid error:"java.exe" exited with code 1.A part of building output as follows:
PROGUARD : warning : there were 220 unresolved references to classes or interfaces.
             You may need to specify additional library jars (using '-libraryjars').
    PROGUARD : warning : there were 10 unresolved references to program class members.
             Your input classes appear to be inconsistent.
          You should consider explicitly keeping the mentioned class members
          (using '-keep' or '-keepclassmembers').
             You may need to recompile them and try again.
             Alternatively, you may have to specify the option 
             '-dontskipnonpubliclibraryclassmembers'.
    java.io.IOException: Please correct the above warnings first.
    	at proguard.Initializer.execute(Initializer.java:321)
    	at proguard.ProGuard.initialize(ProGuard.java:211)
    	at proguard.ProGuard.execute(ProGuard.java:86)
    	at proguard.ProGuard.main(ProGuard.java:492)
    Picked up JAVA_TOOL_OPTIONS:  -Dfile.encoding=UTF8
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2110,3): error MSB6006: "java.exe" exited with code 1.
Done executing task "Proguard" -- FAILED.
Done building target "_CompileToDalvikWithDx" in project "MultidexCrashTestCore.Droid.csproj" -- FAILED.
Done building project "MultidexCrashTestCore.Droid.csproj" -- FAILED.

So I research and find some text must be added in proguard.cfg and mark as proguard configuration in xamarin:
-dontskipnonpubliclibraryclassmembers
-ignorewarnings 

Now my project build successfully ,But get a startup running crashed information:
[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/AnXinMe.RemoteTv.Droid-1.apk"],nativeLibraryDirectories=[/data/app-lib/AnXinMe.RemoteTv.Droid-1, /vendor/lib, /system/lib]]...
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/AnXinMe.RemoteTv.Droid-1.apk"],nativeLibraryDirectories=[/data/app-lib/AnXinMe.RemoteTv.Droid-1, /vendor/lib, /system/lib]]
Comment 9 Jim Bennett 2016-05-12 04:47:25 UTC
@Atsushi I'm getting the same problem.  I've emailed a sample that reproduces the issue to Ashley Gazich.
Comment 11 Atsushi Eno 2016-05-26 21:05:58 UTC
@Jim: I am not sure if you had "the same problem". Your project didn't enable MultiDex *on Release mode* that resulted in the expected >65536 methods error (reported by dx tool).
After enabling that I don't see the problem at all on our latest master version, so if the option was not the problem for you, the issue seems still fixed.