Forum Xamarin.Android

App crashes if NOT using Shared Runtime

My app has been working fine using Shared Runtime. I now need to distribute it to beta testers, so I unchecked "Use Shared Runtime" in Properties->Android Options. With it unchecked, I am able to build the APK, but when I deploy it to my phone and try to run it, it crashes immediately with a NullReferenceException. The call stack has only one line in it, which is:

0x13 in Android.App.Activity.n_OnPostCreate_Landroid_os_Bundle_ at /Users/builder/data/lanes/3540/1cf254db/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:3445,4 C#

If I go back into Properties and check "Use Shared Runtime" and rebuild, it runs fine.

What could the problem be?


  • MHLDMHLD BRBeta ✭✭

    Are you using Linker?
    I have the same problem when using "Link all assemblies".
    For me, I need to set Linker Behaviour to "Link SDK assemblies only"

  • JosephMartinezJosephMartinez USMember ✭✭

    MHLD, Linking is set to "None".

  • JosephMartinezJosephMartinez USMember ✭✭

    I just tried changing Linking from "None" to "Link SDK assemblies only", and it still doesn't work. Now, I get the following runtime exception:

    System.TypeLoadException: Could not load type 'Java.Lang.Thread' from assembly 'Mono.Android, Version=, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.>

  • MabroukMabrouk USMember ✭✭✭
    edited September 2016

    Hi @JosephMartinez
    I think you just need to build your app and generate the APK in Release mode...

  • JosephMartinezJosephMartinez USMember ✭✭

    That worked, thanks! Strange that simply changing that one setting in Debug mode would give those strange errors.

Sign In or Register to comment.