1

I have a Xamarin project that has been working for some time. We recently (a few months ago) had to enable MultiDex. For some reason yesterday it started to refuse to work on devices with Android 4.2. This had been working fine and I'm not sure what changed to affect it. We are seeing this message in the Android log:

> 01-10 08:12:09.903 E/AndroidRuntime(20781): FATAL EXCEPTION: main
> 01-10 08:12:09.903 E/AndroidRuntime(20781):
> java.lang.RuntimeException: Unable to instantiate application
> mono.android.app.Application: java.lang.ClassNotFoundException: Didn't
> find class "mono.android.app.Application" on path:
> /data/app/com.afs.dsd_mobile-1.apk

From what I can tell this is due to the application class being listed in the wrong classes.dex file. This is based on what I read here: http://www.jon-douglas.com/2016/09/05/xamarin-android-multidex/

However, when I modify the mainClassesDex.bat as suggested, it does not fix the problem. Am I missing something?

P. Mancini
  • 47
  • 7
  • http://stackoverflow.com/questions/26925264/android-support-multidex-library-implementation – Hamidreza Sadegh Jan 11 '17 at 08:05
  • Have you tried using `android.support.multidex.MultiDexApplication` for your `MultiDex` as mentioned in the blog you posted? – Elvis Xia - MSFT Jan 12 '17 at 04:06
  • Seeing that it's trying to find `mono.android.app.Application` on the dex list, it suggests what Elvis Xia is suggesting and also that you may not have the proper startup classes defined in your `classes.dex`(Main dex list). You can view my blog on how to override those values. http://www.jon-douglas.com/2016/09/23/xamarin-android-multidex-keep/ Please note that the simplest way to get a general idea for your `multidex.keep` file is to let it generate as per normal and then copy that into your custom `multidex.keep`. You can then add/subtract which classes you need in the main list. – Jon Douglas Jan 17 '17 at 16:23

1 Answers1

1

This article works for me: https://przemekraciborski.eu/2016/09/30/multidex-in-xamarin

Add new text file to project (ex. multidex.keep), set it’s build action to “MutliDexMainDexList”:

md526383ae8de55e54b0b30f6a8bd5184a3\ThisApplication.class
md576a02dcd2afe330a5b70333d32546ae9\LoginActivity.class
mono/android/app/ApplicationRegistration.class
mono/android/app/NotifyTimeZoneChanges.class
mono/MonoRuntimeProvider.class
mono/MonoPackageManager.class
mono/MonoPackageManager_Resources.class
allanes
  • 21
  • 3