问题
在libil2cpp.so上进行Android(IL2CPP)生产构建时,我想要在发生的崩溃中表征一个调用堆栈,但是一直无法找到该库的符号。
原因
该符号文件每次在ProjectFolder/Temp/ directory下构建时被创建,当编辑器应用退出后被移除,所以您可能看不到它们。
解决方案
每次构建后,您可以从下述位置获得符号:
- ProjectFolder\Temp\StagingArea\libs\x86\libil2cpp.so.debug
- ProjectFolder\Temp\StagingArea\libs\armeabi-v7a\libil2cpp.so.debug
确保在关闭Unity编辑器之前将符号文件复制到不同的文件夹中。您也可以使用下面的后期构建脚本:
using UnityEngine; using System.Collections; using UnityEditor.Callbacks; using UnityEditor; using System.IO; using System; public class MyBuildPostprocessor
{ [PostProcessBuildAttribute()] public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { if (target == BuildTarget.Android) PostProcessAndroidBuild(pathToBuiltProject); } public static void PostProcessAndroidBuild(string pathToBuiltProject) { UnityEditor.ScriptingImplementation backend = UnityEditor.PlayerSettings.GetScriptingBackend(UnityEditor.BuildTargetGroup.Android) as UnityEditor.ScriptingImplementation; if (backend == UnityEditor.ScriptingImplementation.IL2CPP) { CopyAndroidIL2CPPSymbols(pathToBuiltProject, PlayerSettings.Android.targetDevice); } } public static void CopyAndroidIL2CPPSymbols(string pathToBuiltProject, AndroidTargetDevice targetDevice) { string buildName = Path.GetFileNameWithoutExtension(pathToBuiltProject); FileInfo fileInfo = new FileInfo(pathToBuiltProject); string symbolsDir = fileInfo.Directory.Name; symbolsDir = symbolsDir + "/"+buildName+"_IL2CPPSymbols"; CreateDir(symbolsDir); switch (PlayerSettings.Android.targetDevice) { case AndroidTargetDevice.FAT: { CopyARMSymbols(symbolsDir); CopyX86Symbols(symbolsDir); break; } case AndroidTargetDevice.ARMv7: { CopyARMSymbols(symbolsDir); break; } case AndroidTargetDevice.x86: { CopyX86Symbols(symbolsDir); break; } default: break; } } const string libpath = "/../Temp/StagingArea/libs/"; Const string libFilename = "libil2cpp.so.debug"; private static void CopyARMSymbols(string symbolsDir) { string sourcefileARM = Application.dataPath + libpath + "armeabi-v7a/" + libFilename; CreateDir(symbolsDir + "/armeabi-v7a/"); File.Copy(sourcefileARM, symbolsDir + "/armeabi-v7a/libil2cpp.so.debug"); } private static void CopyX86Symbols(string symbolsDir) { string sourcefileX86 = Application.dataPath + libpath + "x86/libil2cpp.so.debug"; File.Copy(sourcefileX86, symbolsDir + "/x86/libil2cpp.so.debug"); } public static void CreateDir(string path) { if (Directory.Exists(path)) return; Directory.CreateDirectory(path); } }
更多信息
欲了解更多信息,请参考下述文档:
- An introduction to IL2CPP internals
- How can I get symbols in Instruments during profiling?
- How can I symbolicate iOS crash logs from Projects generated with Cloud Build?
- How to symbolicate iOS and tvOS crash logs
- How do you debug on Android?
- IL2CPP documentation
评论
0 条评论
文章评论已关闭。