When I launch a debug session for my Xamarin.Forms Android project, it crashes instantly, with the following error message:
java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
I'm using Shared Runtime and Fast Deploy, although inactivating either doesn't seem to solve my problem.
What does solve my problem, however, is uninstalling the application manually from the device. Then it'll work for one debug session, but as soon as I start the next one, the same error is back.
It seems to me that the application is somehow unable to find the Mono Shared Runtime if it was installed in a previous debug session, but I can't for the life of me see why.
Here are the steps to go through when trying to fix something like this:
Mono Shared Runtime
first but it won't hurt to try to remove all of them):
If these don't fix the issue, you should post more from the error log. What I'm looking for is a few lines after the main exception definitions to see the stacktrace, like this (mainly the lines starting with at):
java.lang.RuntimeException: Unable to start activity ComponentInfo{plp.cs4b.thesis.drawitapp/plp.cs4b.thesis.drawitapp.PlayGame}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String plp.cs4b.thesis.drawitapp.Player.getName()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
When working with Xamarin and Android, the error might not always be where the exception seems to be pointing at. That's why it's worth looking into it deeper in a situation like this.
According to two other posts on SO found here:
Xamarin.Forms "App has stopped working" on android
Why does my Xamarin Android application suddenly require external storage permissions?
It looks like you "might" be missing the external storage permission, which usually is in the AssemblyInfo.cs
file:[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
Or you can set it in the AndroidManifest.xml
file.
Or instead as the author of the first question posted his answer, he just changed the location of install to internal.
I suggest that this could be worth checking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With