Xamarin.Forms app for Android starts at startup

When I start a debugging session for my Android project Xamarin.Forms, it instantly fails, with the following error message:

java.lang.RuntimeException: cannot get the mono.MonoRuntimeProvider provider: java.lang.NullPointerException: attempt to call the virtual method 'java.lang.String java.io.File.getAbsolutePath ()' to reference a null object

I use Shared Runtime and Fast Deploy, although inactivation either does not help to solve my problem.

However, the solution to my problem is to remove the application manually from the device. Then it will work for one debugging session, but as soon as I start the next one, the same error will return.

It seems to me that the application somehow cannot find the Mono Shared Runtime if it was installed in a previous debugging session, but I can’t understand for life why.

+8
c # xamarin xamarin.android xamarin.forms
source share
3 answers

Here are the steps to take when trying to fix something like this:

  • Are you using the latest stable version of Xamarin? If not, please update.
  • As mentioned in the comments, you should also try to remove the Mono runtime from your device. What you are looking for are the following items in the list of installed applications (at first I will only remove Mono Shared Runtime , but I will not be able to remove all of them):
    • Monoprocessed runtime
    • Mono Android-x Support
    • Xamarin.Android API-X Support
  • Clear the solution and try again.

If this does not fix the problem, you should post more in the error log. I am looking for a few lines after the basic exception definitions to see a stacktrace, for example (mostly lines starting with):

 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 may not always be where the exception seems to indicate. That is why it is worth considering it deeper in such a situation.

+2
source share

According to two other SO posts that can be found here:
Xamarin.Forms "application stopped working" on android
Why does the Xamarin Android app suddenly require external storage permissions?
It looks like you β€œmay” not have permission to external storage, which is usually located in the AssemblyInfo.cs file:
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)] Or you can install it in the AndroidManifest.xml file.
Or instead, when the author of the first question sent his answer, he simply changed the installation location to the internal one.
I suggest that this can be verified.

+1
source share

Try to delete all the bin and obj folders in your project. Then clean and restore.

-one
source share

All Articles