Symptoms
I want to symbolicate a call stack from a crash that happened on my Android (IL2CPP) production build in libil2cpp.so, but I have been unable to find the symbols for that library.
Cause
The symbols files are created for each build in the ProjectFolder/Temp/ directory and removed when the Editor application is exited, which is why you may not have seen them.
Resolution
You can get the symbols from the following locations after each build:
- ProjectFolder\Temp\StagingArea\libs\x86\libil2cpp.so.debug
- ProjectFolder\Temp\StagingArea\libs\armeabi-v7a\libil2cpp.so.debug
Make sure to not close the Unity Editor before copying the symbols files to a different folder.
You can also use a post-process build script like the one below:
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); } }
More Information
For more information, consult the following documentation:
Comments
3 comments
Hi,
Is this still accurate? I'm trying to upload symbols to Crashlytics for Android IL2CPP build.
Do we definitely want "libil2cpp.so.debug" even for non development builds?
It seems like there is an error or "libil2cpp.so.debug" has been moved to "/StagingArea/symbols/"
Thank you,
Niall
how to get crash trace for a il2cpp build?
In old mono builds, I could use addr2line? in il2cpp builds? how to use libil2cpp.so.debug? why I always get meanningless line like "
??
??:0" in addr2line?
I also would like to know if anyone has figured out why some of the lines output by addr2line end up being empty and completely useless like this:
??
??:0
I've used both the libil2cpp.sym.so and the libunity.sym.so to get a parts of a call stack deobfuscated, but there are still gaps like the above - why? Are there more symbols Unity generates that we need to run through the addr2line tool?
Please sign in to leave a comment.