关注

安卓(IL2CPP)构建时,在哪里可以获取Libil2cpp.So库的符号文件,以便表征生产构建中来自崩溃的堆栈调用?

问题

在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); } } 

更多信息

欲了解更多信息,请参考下述文档:

 

这篇文章有帮助吗?
1 人中有 1 人觉得有帮助
还有其它问题?提交请求

0 评论

登录写评论。