来自崩溃日志Xamarin.iOS的更多细节

时间:2017-09-05 07:43:37

标签: xamarin.ios crash

我的测试航班用户每次加载应用时都会遇到崩溃。我无法在我的测试设备或模拟器上重现这一点。

我有崩溃报告,相信我已经完全符号化了blog

但是我无法将错误映射回我的代码:

Date/Time:           2017-09-04 20:37:34.8879 +0100
Launch Time:         2017-09-04 20:36:50.5258 +0100
OS Version:          iPhone OS 10.2.1 (14D27)
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000185433014 __pthread_kill + 8
1   libsystem_pthread.dylib         0x00000001854fb450 pthread_kill + 112 (pthread.c:1366)
2   libsystem_c.dylib               0x00000001853a7400 abort + 140 (abort.c:91)
3   planit                          0x0000000101235da8 mono_handle_native_crash (mini-exceptions.c:2548)
4   libsystem_platform.dylib        0x00000001854f5348 _sigtramp + 52 (sigtramp.c:115)
5   libsystem_pthread.dylib         0x00000001854fb450 pthread_kill + 112 (pthread.c:1366)
6   libsystem_c.dylib               0x00000001853a7400 abort + 140 (abort.c:91)
7   planit                          0x0000000101333414 xamarin_printf (runtime.m:2218)
8   planit                          0x0000000101271a9c mono_invoke_unhandled_exception_hook (exception.c:1084)
9   planit                          0x00000001012359e4 mono_handle_exception_internal (mini-exceptions.c:1886)
10  planit                          0x0000000101234a84 mono_handle_exception (mini-exceptions.c:2117)
11  planit                          0x000000010122d458 mono_arm_throw_exception (exceptions-arm64.c:411)
12  planit                          0x000000010041c278 throw_exception + 168
13  planit                          0x000000010032289c System_Runtime_ExceptionServices_ExceptionDispatchInfo_Throw + 44
14  planit                          0x00000001003252e4 System_Runtime_CompilerServices_AsyncMethodBuilderCore__c__ThrowAsyncb__6_0_object + 84
15  planit                          0x0000000100c2f808 UIKit_UIKitSynchronizationContext__Postc__AnonStorey0__m__0 (UIKitSynchronizationContext.cs:24)
16  planit                          0x0000000100c1be34 Foundation_NSAsyncActionDispatcher_Apply (NSAction.cs:163)
17  planit                          0x00000001003ecc24 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244
18  planit                          0x0000000101243010 mono_jit_runtime_invoke (mini-runtime.c:2526)
19  planit                          0x00000001012a7df0 do_runtime_invoke (object.c:2829)
20  planit                          0x00000001012a7d50 mono_runtime_invoke (object.c:2983)
21  planit                          0x00000001000a8204 native_to_managed_trampoline_1(objc_object*, objc_selector*, _MonoMethod**, unsigned int) (registrar.m:25)
22  planit                          0x00000001000a853c -[__MonoMac_NSAsyncActionDispatcher xamarinApplySelector] (registrar.m:4355)
23  Foundation                      0x0000000186f79048 __NSThreadPerformPerform + 340 (NSThread.m:1247)
24  CoreFoundation                  0x0000000186412b5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1943)
25  CoreFoundation                  0x00000001864124a4 __CFRunLoopDoSources0 + 524 (CFRunLoop.c:1989)
26  CoreFoundation                  0x00000001864100a4 __CFRunLoopRun + 804 (CFRunLoop.c:2821)
27  CoreFoundation                  0x000000018633e2b8 CFRunLoopRunSpecific + 444 (CFRunLoop.c:3113)
28  GraphicsServices                0x0000000187df2198 GSEventRunModal + 180 (GSEvent.c:2245)
29  UIKit                           0x000000018c3857fc -[UIApplication _run] + 684 (UIApplication.m:2650)
30  UIKit                           0x000000018c380534 UIApplicationMain + 208 (UIApplication.m:4092)
31  planit                          0x0000000100c6fc10 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr (/<unknown>:1)
32  planit                          0x0000000100c2de8c UIKit_UIApplication_Main_string___intptr_intptr (UIApplication.cs:79)
33  planit                          0x0000000100c2de4c UIKit_UIApplication_Main_string___string_string (UIApplication.cs:63)
34  planit                          0x00000001000cbef4 planit_Application_Main_string__ (Main.cs:13)
35  planit                          0x00000001003ecc24 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244
36  planit                          0x0000000101243010 mono_jit_runtime_invoke (mini-runtime.c:2526)
37  planit                          0x00000001012a7df0 do_runtime_invoke (object.c:2829)
38  planit                          0x00000001012aa7bc do_exec_main_checked (object.c:4624)
39  planit                          0x000000010122cc68 mono_jit_exec (driver.g.c:1040)
40  planit                          0x0000000101337168 xamarin_main (monotouch-main.m:482)
41  planit                          0x00000001000c75bc main (main.m:79)
42  libdyld.dylib                   0x00000001853215b8 start + 4

有人能指出我正确的方向吗?

1 个答案:

答案 0 :(得分:1)

我们跟踪导致我们要求测试人员查看的应用程序崩溃的异常的方法是通过挂钩到iOS的全局异常处理程序,并使用我们编写的类来将信息记录到IO。 / p>

类别:

using System;
using System.IO;
using UIKit;

namespace namespace.TestingLogs
{
    public static class ApplicationLog
    {
        private static string _filename = "LogFile-";

        public static void CreateFile(string SessionFilename)
        {
            _filename += SessionFilename;

            var docs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename = Path.Combine(docs, _filename);
            var Device = UIDevice.CurrentDevice;
            File.AppendAllText(filename, ("======Device Information======" + Environment.NewLine));
            File.AppendAllText(filename, ("Battery Level: " + Device.BatteryLevel + Environment.NewLine));
            File.AppendAllText(filename, ("Model: " + Device.Model + Environment.NewLine));
            File.AppendAllText(filename, ("System Version: " + Device.SystemVersion + Environment.NewLine));
            File.AppendAllText(filename, ("[" + DateTime.UtcNow.ToString() + "]" + "======Start Log======" + Environment.NewLine + Environment.NewLine));
            Console.WriteLine("[] = " + filename);
        }

        public static void AppendFile(string appendText)
        {
            var txt = Environment.NewLine + appendText;

            var docs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename = Path.Combine(docs, _filename);
            File.AppendAllText(filename, txt);
        }
    }

    public class ExitAppException : Exception
    {
        public ExitAppException() { }
        public ExitAppException(string message) : base(message) { }
        public ExitAppException(string message, Exception inner) :
        base(message, inner)
        { }
    }
}

通过在'FinishedLaunching'方法中执行以下操作,挂钩到AppDelegate.cs中的全局未处理事件:

        AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) =>
        {
            try
            {
                //Record the error in our application logs

                ApplicationLog.AppendFile(
                    DateTime.Now.ToString() + "  :  " + "[CRITICAL GLOBALLY HANDLED EXCEPTION] - Critical exception has been hit! - Message: " + e.ExceptionObject +
                        Environment.NewLine + Environment.NewLine +
                            "========= Critcal Error has been hit, application closed =========" +
                                Environment.NewLine + Environment.NewLine
                    );
            }
            catch (Exception genEx)
            {
                var Error = genEx.Message;
            }
        };

使用最适合你的任何措辞。随意使用字符串生成器而不是我们的方式,但一般概念是相同的。然后,您的用户可以下载“macgo iphone explorer”(它是免费的)并访问应用程序文档文件夹,日志文件将在那里,因此他们只需通过电子邮件发送给您。希望这有点帮助。