unity Symbolicate Android crash

在发布模式下构建Unity项目时,符号不会打包到APK中。如果应用崩溃,调用堆栈只会显示内存地址。要定位Android崩溃,需要找到如Il2cpp.so和libunity.so的符号文件。addr2line工具在Android NDK中,需要配置符号路径来解析libunity.so、libmain.so和libil2cpp.so等库。在Project Settings中设置符号路径,并根据脚本后端、构建配置和CPU架构选择正确的路径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考链接:https://support.unity.com/hc/en-us/articles/115000292166-Symbolicate-Android-crash

https://docs.unity3d.com/Packages/com.unity.mobile.android-logcat@1.2/manual/StacktraceUtility.html

https://docs.unity3d.com/Packages/com.unity.mobile.android-logcat@1.2/manual/MemoryWindow.html
摘抄几个要点:
When you build in release mode, the symbols are not packed with the APK. If your app crashes, the call stack will only show the memory address.

You can find the Android symbols here:
Il2cpp.so: this file is generated when you build your project and is located in the symbols.zip file that is created next to the APK, abb, or Gradle project.
libunity.so: this file is located in the Unity installation folder:
/PlaybackEngines/AndroidPlayer/Variations/il2cpp/Development/Symbols
在这里插入图片描述
When you build using IL2CPP, if the Strip Engine Code option is enabled, Unity creates a new libunity.so that it is different from the installation folder, so you need to use this for the symbolization.

You can find the addr2line tool in your Android NDK at the following address:
/android-ndk_auto-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-addr2line

Android Logcat Settings

Configure Symbol Paths
Before using the tool, you need to setup symbol paths in the Project Settings->Analysis->Android Logcat Settings, so symbols for libraries like libunity.so, libmain.so, libil2cpp.so can be found. Click + button and pick a symbol path from Unity installation or a custom location.

Note: Symbol Paths settings are saved in project user settings.

libmain.so - native library containing Unity loader code.
libunity.so - native library containing Unity engine code.
libil2cpp.so - native library containing user code, C# from Unity project ends up here.
Symbol path varies dependening on:

Scripting backend mono or il2cpp
Build configuration - development (pick Development folder) or non development (pick Release folder)
CPU architecture
Strip Engine Code setting in Player Settings (only applies for il2cpp)
Symbols for libil2cpp.so:

Are located in *.symbols.zip file, assuming you selected Create symbols.zip in Build Settings window.
Symbols for libunity.so:

If Strip Engine Code is enabled (only applies for il2cpp), libunity.so symbols will be located in *.symbols.zip file.
If Strip Engine Code is disabled, libunity.so symbols will be located in Unity installation folder, use + button to navigate to correct scripting backend/build configuration/CPU architecture folder.
Symbols for libmain.so:

Are always located in Unity installation folder, use + button to navigate to correct scripting backend/build configuration/CPU architecture folder.
When resolving stacktrace, the tool will go through symbol path list and use the first located symbol file, if you use more than one symbol path, be wary if symbol with same file name exists in both folder, as only the first one found will be used.

Note: You can specify the symbol path without CPU architecture …AndroidPlayer\Variations\il2cpp\Development\Symbols (instead of …AndroidPlayer\Variations\il2cpp\Development\Symbols\arm64-v8a), in that case the utility will try to guess the CPU architecture and will append the missing subfolder. This is only possible if crash line has information about ABI, for ex.,

2020/10/30 16:38:32.985 19060 19081 Error AndroidRuntime #3 pc 000000000019a6f8 /data/app/~~Ctx1WDf6mhlw6jvONDIlaQ==/com.DefaultCompany.ForceCrash-2XwBC-UrBxWJCR2aVVdY1A==/lib/arm64/libil2cpp.so
As you see the crash line has path which contains …/lib/arm64/libil2cpp.so, thus it’s possible to guess that this is arm64-v8a cpu architecture.

Note: If you provide an invalid symbol path, the function names will still be resolved, but they will not be correct. Android tools don’t validate if a specific address belongs to a specific symbol file.

Configure Regex
Can be found in Preferences->Analysis->Android Logcat Settings

This list contains the default regexes how to parse address and library name from entry line. You can add your own custom regex to resolve address and library name, just be sure capture groups - libName and address exist.

Note: Regex settings are saved per user.

Quick steps
Copy paste the log contain the crash to Original text area
Click Resolve Stacktraces
The resolved log will be present in Resolved text area
Device Screen Capture

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值