简体   繁体   English

我的 Xamarin.Android 应用程序有时会在启动时崩溃

[英]My Xamarin.Android app sometimes crashes on launch

Recently, my Xamarin.Android app has started to crash on launch, caused by:最近,我的 Xamarin.Android 应用程序在启动时开始崩溃,原因如下:

Java.Lang.ClassNotFoundException: mono.android.app.Application 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).不幸的是,发生了同样的异常(除了因为找不到我的班级而不是 Mono 的班级而感到不安)。 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).各种 Google 搜索、Xamarin 论坛主题和 StackOverflow 问题都没有太大帮助(实际上,重建和制作自定义应用程序类的想法来自于此)。 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?我怎样才能解决这个问题?

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).我做了一些乱七八糟的事情,并在我的项目设置中关闭了共享的 Mono 运行时,这似乎已经解决了问题(至少现在是这样)。 I'll update the question if it stops working again.如果它再次停止工作,我会更新问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM