I was working with my app today, which until now has been using Shared Runtime in development mode. I made a small code change and tried to restart the app, but it started crashing instantly (I could see the splash screen for maybe a tenth of a second before it'd go back to my home screen). Visual Studio told me "XAML Hot Reload Stopped" at the bottom and there was absolutely zero output in the Output Window. I tried uninstalling the app, Xamarin, and Mono runtimes using the App Manager in Android and tried building again. It still crashed, so I undid the code changes I made, cleared my bin/obj folders, and uninstalled the app again using App Manager. Even after reverting my code changes that "seemingly caused" the crashing, I still can't get the app to run.
If I attach to Logcat and try and start the app, I see a stack trace printed out:
03-05 15:30:36.440 18146 18146 D AndroidRuntime: Shutting down VM 03-05 15:30:36.441 18146 18146 E AndroidRuntime: FATAL EXCEPTION: main 03-05 15:30:36.441 18146 18146 E AndroidRuntime: Process: com.<company>.<appid>, PID: 18146 03-05 15:30:36.441 18146 18146 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_28! 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:7369) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.app.ActivityThread.access$1400(ActivityThread.java:267) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.os.Looper.loop(Looper.java:237) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7762) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: Caused by: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_28! 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:38) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:7364) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: ... 10 more 03-05 15:30:36.441 18146 18146 E AndroidRuntime: Caused by: android.content.pm.PackageManager$NameNotFoundException: Mono.Android.Platform.ApiLevel_28 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.app.ApplicationPackageManager.getApplicationInfoAsUser(ApplicationPackageManager.java:490) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:471) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:35) 03-05 15:30:36.441 18146 18146 E AndroidRuntime: ... 11 more
After searching Google for the exception message, all I've been able to find is that I need to disable Shared Runtime. Fun story, Visual Studio won't actually let me do this. Clicking the "Use Shared Runtime" checkbox doesn't do a thing (it stays checked). Putting <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
in my .csproj
file works and lets the app run, but it was working before with Shared Runtime. Why would it just randomly refuse to run using Shared Runtime all of a sudden? I've tried clearing all bin/obj folders with Studio closed, using adb shell pm uninstall
to completely remove my app, doing a full solution Clean and then Rebuild, and it still refuses to run unless I leave AndroidUseSharedRuntime
set to False
.
To be clear, the only thing I changed before it broke was putting a small piece of code into a Page, and I've since removed that code. I didn't close Studio or change any packages between when it was working and when it wasn't.