您需要使用发布版本的符号(构建的 msym 和构建应用程序必须来自同一个构建)通过
mono-symbolicate
来将“原生”Android崩溃报告进行符号化。一些崩溃报告服务直接支持Xamarin,并允许您上传构建的 msym 文件并自动运行
mono-symbolicate
,而其他一些则不支持,因此需要您手动完成(或者一些支持Web钩子,您可以自己实现每个收到的崩溃报告运行它,在Fabric上我是这样做的)。
mono-symbolicate
Usage: symbolicate [options] <msym dir> <input file>
symbolicate [options] store-symbols <msym dir> [<dir>]+
Available options:
-h, --help Show this help
-q Quiet, warnings are not displayed
-v Verbose, log debug messages
接下来,获取一个未处理异常的崩溃日志
adb logcat -d > errors.txt
最后,使用mono-symbolicate将错误转换为包含文件和行号的格式:
mono-symbolicate path-to-dll-in-.mSYM-directory path-to-errors.txt
例如,给定一个包含以下内容的errors.txt文件:
I/MonoDroid( 1545): System.Exception: wow it broke
I/MonoDroid( 1545): at CrashApp.MainActivity+<OnCreate>c__AnonStorey0.<>m__0 (System.Object , System.EventArgs ) [0x00030] in <filename unknown>:0
I/MonoDroid( 1545): at Android.Views.View+IOnClickListenerImplementor.OnClick (Android.Views.View v) [0x00014] in <filename unknown>:0
I/MonoDroid( 1545): at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (IntPtr jnienv, IntPtr native__this, IntPtr native_v) [0x00011] in <filename unknown>:0
I/MonoDroid( 1545): at (wrapper dynamic-method) System.Object:5616285d-461b-4005-a31b-d4637a8cdddc (intptr,intptr,intptr)
mono-symbolicate将把上述内容翻译成:
I/MonoDroid( 1545): System.Exception: wow it broke
I/MonoDroid( 1545): at CrashApp.MainActivity+<OnCreate>c__AnonStorey0.<>m__0 (System.Object , System.EventArgs ) [0x00030] in /Users/dean/Projects/CrashApp/CrashApp/MainActivity.cs:30
I/MonoDroid( 1545): at Android.Views.View+IOnClickListenerImplementor.OnClick (Android.Views.View v) [0x00014] in /Users/dean/Documents/Sandbox/Xamarin/dellismonodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Webkit.WebBackForwardList.cs:68
I/MonoDroid( 1545): at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (IntPtr jnienv, IntPtr native__this, IntPtr native_v) [0x00011] in /Users/dean/Documents/Sandbox/Xamarin/dellismonodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Webkit.WebBackForwardList.cs:23
I/MonoDroid( 1545): at (wrapper dynamic-method) System.Object:5616285d-461b-4005-a31b-d4637a8cdddc (intptr,intptr,intptr)