Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[monodroid]
AndroidEnablePreloadAssemblies
causes runtime crash.
Fixes dotnet#5838 Turning off Assembly preloading results in the following runtime error ``` android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object at MyLibrary.MainActivity.OnCreate(Bundle bundle) at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) at com.xamarin.classlibrarymainlauncherruns.MainActivity.n_onCreate(Native Method) at com.xamarin.classlibrarymainlauncherruns.MainActivity.onCreate(MainActivity.java:29) ``` This only occurs on one unit test [`DebuggingTest.ClassLibraryMainLauncherRuns()`](https://github.com/xamarin/xamarin-android/blob/bf4f4f42af26cdddb46087deed59aae8424f7942/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs#L74-L124) This happens because the `MainActivity` in that test is in a library project. As a result when we do not preload assemblies the main assembly is NEVER loaded. This means `ResourceIdManager.UpdateIdValues()` never finds the `Resource` class from the main assembly, and as such none of the ids are updated. To fix this , when running without assembly preloading we will ALWAYS load the first assembly in the assembly list. This will always be the main assembly and will contain the `Resource` class.
- Loading branch information