gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 15:39:40 24 4
gpt4 key购买 nike

我的 xamarin android 应用程序运行良好,每次启动时都开始崩溃,出现此异常。

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

有没有人遇到过这个异常并且知道该怎么做?
泰!

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);
}
}

所以似乎 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 的。

最佳答案

就我而言,该问题是由使用 App Center 尚不支持的 Android SDK 8.1 引起的。
我不得不降级到 SDK 8.0,现在构建工作正常。

App Center 团队 promise 添加对 SDK 8.1 的支持,但他们还没有 ETA。

关于xamarin.android - 'Android.Runtime.UncaughtExceptionHandler' 的类型初始值设定项引发异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49188728/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com