There are a quite a few posts scattered around about this but my question is:
Has anyone managed to successfully build a MultiDex enabled app that utilizes a custom Application class that will run on pre - Lollipop devices?
For people who wanted to learn more about it keep reading.
The issues is that when creating a MultiDex app that uses a custom application class (I'd guess the vast majority of apps over the 65k limit would be in this category), that class does not end up in the first dex file which causes devices without built in MultiDex support to crash with the error
[AndroidRuntime] java.lang.RuntimeException: Unable to instantiate application md5a3fc106bb082f0a6c07b5025b0a464e3.MyApplication: java.lang.ClassNotFoundException: Didn't find class "md5a3fc106bb082f0a6c07b5025b0a464e3.MyApplication" on path
I've tried all of the listed solutions, including from Xamarin support in order to get to this to work.
There are numerous articles about it:
https://bugzilla.xamarin.com/show_bug.cgi?id=35491 https://forums.xamarin.com/discussion/57485/multiple-issues-with-library-project-and-multidex
What I've done:
I have created a custom MultiDexMainDexList file by using a modified version of the mainDexClasses.bat file (as per the articles).
I then modified the command that Xamarin throws at it to use the full path names as Xamarin just tries to use "obj\Debug"
mainDexClasses_fixed.bat --output C:\Users\bradl_000\Documents\blocke79\App\App\obj\Debug\multidex.keep "'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v6.0\mono.android.jar';'C:\androidsdk\extras\android\support\multidex\library\libs\android-support-multidex.jar';'C:\Users\bradl_000\Documents\blocke79\App\App\obj\Debug__library_projects__\Aniways.AndroidBinding\library_project_imports\aniways-V2.3.08.jar'" (have trimmed this massive list for reading)
This produces a MultiDexMainDexList file with all of the classes in my project. which I then add this to my project with the new build action of "MultiDexMainDexList" (only available in Alpha channel v6).
This gets rid of the error regarding the application class but instead throws a new error regarding not being able to find the PackageManager class.
java.lang.NoClassDefFoundError%3A+mono.MonoPackageManager_Resources
I then started thinking that I should trim down the entire list of classes in the MultiDexMainDexList file and keep only the ones that I think my custom application class needs to load. No matter what I've done to this list I still get the error regarding the PackageManager. The package manager class is included and I have tried playing with the order of the classes in case that made a difference.
mono/MonoPackageManager.class
Has anyone traveled the same path with more success than me? Is it even possible?