编程语言
首页 > 编程语言> > c# – Android的不可用组件HockeyApp(Xamarin组件商店)

c# – Android的不可用组件HockeyApp(Xamarin组件商店)

作者:互联网

我试图将上面提到的组件投入使用.

http://components.xamarin.com/view/hockeyappios

我创建了一个基于Xamarin Studio模板的非常简单的项目(Android Ice Cream Sandwich Application)
然后我添加了向HockeyApp发送异常的必要代码.此代码在下一页中介绍

http://components.xamarin.com/gettingstarted/hockeyappandroid

不幸的是,我发现存储异常信息文件存在一个主要问题

HockeyApp.ManagedExceptionHandler.SaveException (e.ExceptionObject)

此调用会导致以下错误

[mono-rt] Stacktrace:
[mono-rt] 
[mono-rt]   at <unknown> <0xffffffff>
[mono-rt]   at (wrapper managed-to-native) object.wrapper_native_0x407339b5 (intptr,string) <IL 0x00038, 0xffffffff>
[mono-rt]   at Android.Runtime.JNIEnv.FindClass (string) [0x00000] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:377
[mono-rt]   at Android.Runtime.JNIEnv.FindClass (string,intptr&) [0x00014] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:409
[mono-rt]   at Android.OS.Looper.get_class_ref () [0x00000] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.OS.Looper.cs:14
[mono-rt]   at Android.OS.Looper.get_MainLooper () [0x00014] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.OS.Looper.cs:34
[mono-rt]   at Android.App.SyncContext.Send (System.Threading.SendOrPostCallback,object) [0x00014] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:24
[mono-rt]   at HockeyApp.ManagedExceptionHandler.Save (string) <IL 0x0001f, 0x00157>
[mono-rt]   at HockeyApp.ManagedExceptionHandler.SaveException (object) <IL 0x00006, 0x0006b>
[mono-rt]   at HockeyAppTest.App.<OnCreate>b__0 (object,System.UnhandledExceptionEventArgs) [0x00002] in c:\Snapshot\HockeyAppTest\Application.cs:33
[mono-rt]   at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object_object (object,intptr,intptr,intptr) <IL 0x0005a, 0xffffffff>
[mono-rt] 
[mono-rt] =================================================================
[mono-rt] Got a SIGSEGV while executing native code. This usually indicates
[mono-rt] a fatal error in the mono runtime or one of the native libraries 
[mono-rt] used by your application.
[mono-rt] =================================================================

在检查问题时,我发现了以下信息

>可以毫无问题地存储处理的异常
>仅在AppDomain.CurrentDomain.UnhandledException处理程序中出现问题

然后我在AppDomain.CurrentDomain.UnhandledException处理程序中尝试了以下代码

string eStr = e.ExceptionObject.ToString();
Java.Lang.Throwable thr = new Java.Lang.Throwable(eStr);

此代码导致非常类似的错误

[mono-rt] Stacktrace:
[mono-rt] 
[mono-rt]   at <unknown> <0xffffffff>
[mono-rt]   at (wrapper managed-to-native) object.wrapper_native_0x4072e4e5 (intptr,intptr,int) <IL 0x00027, 0xffffffff>
[mono-rt]   at Android.Runtime.JNIEnv.NewString (string) [0x00017] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:666
[mono-rt]   at Java.Lang.Throwable..ctor (string) [0x00022] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Java.Lang.Throwable.cs:50
[mono-rt]   at HockeyAppTest.App.<OnCreate>b__0 (object,System.UnhandledExceptionEventArgs) [0x0000d] in c:\Snapshot\HockeyAppTest\Application.cs:34
[mono-rt]   at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object_object (object,intptr,intptr,intptr) <IL 0x0005a, 0xffffffff>

这是代码调用的一般问题,在AppDomain.CurrentDomain.UnhandledException中使用“java binding”吗?

解决方法:

第二个错误是因为未处理的c#异常的异常处理程序在一个没有真正具有JNI访问权限的有趣空间中运行.

通过直接写出HockeyApp格式的C#异常,并且只将Java异常直接报告给HockeyApp库,您可以在没有带有一点包装胶的组件的情况下使其工作.

这就是我使用的https://github.com/tpurtell/AndroidHockeyApp/blob/master/Additions/TraceWriter.cs#L84

HockeyApp对于Exception的格式化有点迂腐,所以这段代码并不完美,会导致一些堆栈跟踪在他们的网站上通过异常名称组合在一起,但例外情况都会在这里完成.

标签:c,android,xamarin,xamarin-android,hockeyapp
来源: https://codeday.me/bug/20190624/1278401.html