一、安装Android Logcat插件
1、新建空白unity工程,打开PackageManager窗口,菜单栏Window/PackageManager
2、PackageManager中安装Android Logcat日志工具
3、安装AndroidLogcat完成
二、获取Create symbols.zip中的libil2cpp.sym.so文件
1.打包
在出包时勾选Create symbols.zip选项,在PlayerSettings面板中,出包选项从mono切换到il2cpp,然后Build包
出包完成,目录会有一个apk和一个zip的符号表压缩包
三、获取libunity.sym.so文件
在Unity编辑器中,libunity.sym.so文件通常位于Unity安装目录下的Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono\Release\Symbols文件夹中。
具体路径是:{Unity安装目录}\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono\Release\Symbols
请注意,这个路径是基于默认的Unity安装目录,并且可能因为不同的Unity版本或自定义安装路径而有所变化。如果你的Unity安装目录有所不同,你可以通过搜索文件名或在Unity编辑器中使用"Reveal in Finder"(在资源视图中右键点击文件,选择"Show in Explorer")等选项来找到libunity.sym.so文件的确切位置。
四、Crash日志解析
1.菜单栏打开AndroidLogcat工具,Window/Analysis/AndroidLogcat
2.配置符号表
右上角,点击Tools,点击Stacktrace Utility
点击Configure Symbol Path,然后弹出的配置界面点击+号
点击Pick Custom Location,选择刚刚解压的符号表文件夹
3.崩溃堆栈格式
找到一个firebase上的崩溃堆栈:
Fatal Exception: Tombstone: Version '2019.4.40f1 (ffc62b691db5)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'armeabi-v7a' Build fingerprint: 'TECNO/BE8-RU/TECNO-BE8:12/SP1A.210812.016/230105V142:user/release-keys' Revision: '0' ABI: 'arm' Timestamp: 2024-01-24 10:11:45+0400 pid: 20495, tid: 20628, name: UnityMain >>> <<< uid: 10182 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 Cause: null pointer dereference r0 00000000 r1 00000000 r2 00000002 r3 00000001 r4 06eca250 r5 44fb7fd0 r6 6eaf1af5 r7 00000020 r8 7a5c083c r9 a7e97710 r10 00000000 r11 7a5c07e0 ip 7a5c0740 sp 7a5c07d0 lr aabb9191 pc 5a864344 #00 pc 0x1322344 libil2cpp.so (libil2cpp.0x1322344) #01 pc 0x1322158 libil2cpp.so (libil2cpp.0x1322158) #02 pc 0x1321f00 libil2cpp.so (libil2cpp.0x1321f00) #03 pc 0x1321cf4 libil2cpp.so (libil2cpp.0x1321cf4) #04 pc 0x1322690 libil2cpp.so (libil2cpp.0x1322690) #05 pc 0x353445 libunity.so (libunity.0x353445) #06 pc 0x35e337 libunity.so (libunity.0x35e337) #07 pc 0x35db77 libunity.so (libunity.0x35db77) #08 pc 0x35e043 libunity.so (libunity.0x35e043) #09 pc 0x3542a9 libunity.so (libunity.0x3542a9) #10 pc 0x3542c5 libunity.so (libunity.0x3542c5) #11 pc 0x354461 libunity.so (libunity.0x354461) #12 pc 0x4313bf libunity.so (libunity.0x4313bf) #13 pc 0x43f191 libunity.so (libunity.0x43f191) #14 pc 0xac07b base.odex (base.0xac07b)
AndroidLogcat可解析的崩溃堆栈格式为:
#xx pc 32位地址(即8位16进制数,要去掉x,不足在前面补0) /{ABI}/{xxx}.so
#00 pc 01322344 /arm/libil2cpp.so #01 pc 01322158 /arm/libil2cpp.so #02 pc 01321f00 /arm/libil2cpp.so #03 pc 01321cf4 /arm/libil2cpp.so #04 pc 01322690 /arm/libil2cpp.so #05 pc 00353445 /arm/libunity.so #06 pc 0035e337 /arm/libunity.so #07 pc 0035db77 /arm/libunity.so #08 pc 0035e043 /arm/libunity.so #09 pc 003542a9 /arm/libunity.so #10 pc 003542c5 /arm/libunity.so #11 pc 00354461 /arm/libunity.so #12 pc 004313bf /arm/libunity.so #13 pc 0043f191 /arm/libunity.so
4.选择abi对应的符号表
ABI:arm=>armeabi-v7a arm64=>arm64-v8a (还有其他如x86、x86_64)