My Xamarin.Android app sometimes crashes on launch

坚强是说给别人听的谎言 提交于 2020-01-04 05:36:29

问题


Recently, my Xamarin.Android app has started to crash on launch, caused by:

Java.Lang.ClassNotFoundException: mono.android.app.Application

This exception is being thrown more often than not. Usually, a rebuild fixes the issue for a build or two. I tried to combat the issue by making my own application class:

[Application(AllowBackup = true, Debuggable = true, Label = "My Application",
 Theme = "@style/AppBaseTheme", Icon = "@drawable/icon", Logo = "@drawable/icon")]
[MetaData("com.google.android.gms.version", Value = "@integer/google_play_services_version"),
 MetaData("com.google.android.geo.API_KEY", Value = "[redacted]")]
public class MyApplication: Application {
    public MyApplication(IntPtr handle, JniHandleOwnership ownership) : base(handle, ownership) {
    }

    public override void OnCreate() {
        base.OnCreate();
    }
}

Unfortunately, the same exception occurs (except that it's upset about not finding my class, instead of Mono's). Various Google searches, Xamarin Forums threads, and StackOverflow questions haven't helped a whole lot (in fact, the ideas to rebuild and make a custom application class came from that). This issue is really annoying and it is making it hard for me to debug my app. Am I doing something wrong? How can I fix this?


回答1:


I did some messing around and I turned off the shared Mono runtime in my project's settings, and that seems to have solved the problem (for now at least). I'll update the question if it stops working again.



来源:https://stackoverflow.com/questions/36771756/my-xamarin-android-app-sometimes-crashes-on-launch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!