【发布时间】:2018-03-09 07:34:43
【问题描述】:
我的 xamarin android 应用程序运行良好,但每次启动时都会出现此异常。
应用程序是从 appcenter 的构建服务构建的,一如既往。如果我以调试或发布模式在本地构建它,它会正常启动。使用搭载 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
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 最近在 mono 中发生了变化:
但是 DoUnhandledException 没有改变。
-- 编辑 4
在本地构建/发布时工作正常。所以这个问题是 appcenter 特有的。
【问题讨论】:
-
我们也遇到了这个问题。我们在 iOS 上没有遇到任何问题。我们还在启动应用程序时的日志中发现了这一点:03-09 09:51:44.841: W/OpenGLRenderer(2455): 在视图上错误地调用 buildLayer: ShortcutAndWidgetContainer, 破坏层...
-
是的,仅适用于 Android。一些用户也报告了这个问题,但直到现在它都无法重现。
-
我们也会遇到类似的问题。
-
同样的问题,我已经报告给应用中心帮助
-
有人有更新吗?对我来说同样的问题,降级到 8.0 对我不起作用。
标签: xamarin.android mono visual-studio-app-center