In my application when I do a completely clean build (fully deleted bin and obj folders) My application often crashes (~95% of builds) on launch with the message "Unfortunately, MyApp has stopped". The message I can see in the logs is
AndroidRuntime java.lang.RuntimeException: Unable to instantiate application md563d86d3b4ee6b5d12237bf06ae53c0c1.MyApplication: java.lang.ClassNotFoundException: Didn't find class "md563d86d3b4ee6b5d12237bf06ae53c0c1.MyApplication" on path: DexPathList. I have seen other people encounter this error but none of the solutions I have found in the forums and online seem to resolve my problem. I do not have Multi Dex enabled so their is only one dex file. In my solution attempt, turning on Multi Dex did not resolve the problem I am encountering. The application used to work fine prior to upgrading to to the latest stable Xamarin version. Unfortunately, I did not keep a record of what the previous versions I was but it was at least 1.5 years old.
During my investigations I find after building my app I get two classes created in the obj folders. For example with the above crash, the build created:
Additionally we get the ApplicationRegistration.class, ..\obj\Debug\android\bin\classes\mono\android\app\ApplicationRegistration.class making reference to
MyApp.Mobile.Droid.Application.MyApplication, MyApp.Android, Version=126.96.36.19956, Culture=neutral, PublicKeyToken=null 6md529a8003c3c31c6cbd5c7d8e69ed8db67/MyApplication_". I noticed here its using "_md529a8003c3c31c6cbd5c7d8e69ed8db67. However in the classes.dex and classes.zip files I can only see references to md563d86d3b4ee6b5d12237bf06ae53c0c1/MyApplication.class.
This seems to be the root of my problem as different parts of the built application are using different application classes. I cannot figure out how to resolve this issue.
VS 2017 15.5.1
Xamarin Designer 4.8.183
Xamarin.Android SDK 188.8.131.52
Xamarin.iOS and Xamarin.Mac SDK 184.108.40.206
[Application(Debuggable = true, Icon = "@drawable/Icon", Label = "@string/ApplicationName")]
public class MyApplication : Android.App.Application
public MyApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)