'Android.Runtime.UncaughtExceptionHandler'的类型初始值设定项引发了异常

Sof*_*ion 6 mono xamarin.android visual-studio-app-center

我的xamarin安卓应用程序运行正常,每次启动都会因此异常而崩溃.

该应用程序是从appcenter的构建服务构建的,一如既往.如果我在Debug或Release模式下在本地构建它,它会正常启动.使用Android 7设备.

有没有人遇到这个例外,知道该怎么办?
Ty!

18828 W monodroid: Calling into managed runtime init E mono : E mono : Unhandled Exception: E mono : System.TypeInitializationException: The type initializer for 'Android.Runtime.UncaughtExceptionHandler' threw an exception. ---> System.ArgumentNullException: Value cannot be null. E mono : Parameter name: method E mono : at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure, System.Boolean allowClosed) <0x56d026b4 + 0x00d74> in :0 E mono : at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) <0x56d03594 + 0x0001f> in :0 : at Android.Runtime.UncaughtExceptionHandler..cctor () <0x57d908a4 + 0x0003f> in :0 : --- End of inner exception stack trace --- : at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_generic_class_init (intptr) : at Android.Runtime.JNIEnv.Initialize (Android.Runtime.JnienvInitializeArgs* args)

- 编辑

启用所有AOT/LVVM /并发垃圾收集器/ proguard/multidex选项

- 编辑2

错误源代码:https://github.com/xamarin/xamarin-android/blob/master/src/Mono.Android/Android.Runtime/UncaughtExceptionHandler.cs

static UncaughtExceptionHandler ()
    {
        var mono_UnhandledException = typeof (System.Diagnostics.Debugger)
            .GetMethod ("Mono_UnhandledException", BindingFlags.NonPublic | BindingFlags.Static);
        mono_unhandled_exception = (Action<Exception>) Delegate.CreateDelegate (typeof(Action<Exception>), mono_UnhandledException);

        var ad_due = typeof (AppDomain)
            .GetMethod ("DoUnhandledException",
                bindingAttr:  BindingFlags.NonPublic | BindingFlags.Instance,
                binder:       null,
                types:        new []{typeof (UnhandledExceptionEventArgs)},
                modifiers:    null);
        if (ad_due != null) {
            AppDomain_DoUnhandledException  = (Action<AppDomain, UnhandledExceptionEventArgs>) Delegate.CreateDelegate (
                    typeof (Action<AppDomain, UnhandledExceptionEventArgs>), ad_due);
        }
    }
Run Code Online (Sandbox Code Playgroud)

所以似乎mono_UnhandledException为null或AppDomain_DoUnhandledException为null.

将尝试在appcenter中升级或降级单声道版本.应该是错的.

- 编辑3

AppDomain.cs最近改为单声道:

https://github.com/mono/mono/commits/c1cbe060f617707258fd5111fd5ffd7ccd581899/mcs/class/corlib/System/AppDomain.cs

但是DoUnhandledException没有改变.

- 编辑4

在本地构建/发布时工作正常.所以问题是appcenter特有的.

nev*_*nny 1

AppCenter最近发布了与Xamarin.Android 8.2(支持TargetFrameworkVersion:8.1)捆绑的Mono 5.8,为了使用它,请更改您的分支配置 - > Save&Build。

还将该问题提交给 Xamarin.Android 团队进行调查。