How To Decode Unity Crashes On Android

Crashes… of course they’re not our fault !! our code is always the best. It’s someone else’s code that’s bad !! we’re a rare breed of elite ninja developers…

Using crash reporting services helps us get informed about these (services such as: Crashlytics, Raygun, HockeyApp, Crittercism, etc. BTW: I plan to do a post about choosing such a service, stay tuned). But often times, this is not enough, as the crashes to not contain any meaningful function names, and so it’s hard to pinpoint exactly what went wrong.

Unity Crashes on Android

This post deals specifically with crashes on Android that occur inside the Unity engine, in particular, crashes in released games (non ‘development’ builds), where the stack trace may look like this:


As you can see, the crash occurs inside libunity and the stack trace doesn’t contain any function names – only memory addresses. This makes it hard to decide exactly what went wrong.

Decoding ? What For ?

You may ask yourselves – why should i care? after all, this is a crash that occurs in the Unity engine code. There’s nothing i can do to fix it anyway.

This is partly true: yes, you’d probably won’t be able to fix the issue yourself, but understanding the problem is the first step to solving it. After you understand where it happened you can:

  1. Look up the information online – on the Unity forums, Answers site or the  Issue tracker sites.
  2. Open a ticket so Unity developers could have a look at the issue and hopefully fix it (for you and all other developers).

How To Decode ?

Translating the crash stack trace into meaningful function names is pretty simply. You need to use a tool called ‘addr2line’ from the Android NDK (download here). The key to this process is the symbol files that are shipped as part of the Unity installation: these allow translating from memory address to the correct function name.

The Android NDK ships with a number of these tools, each targeting a specific CPU architecture. For Android, the 2 relevant ones are:

  • arm-linux
  • x86 (or x86_64)

Running the tool is done like so: addr2line -Cfe

The Unity symbol files are found under the Unity installation path: <Unity>\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono\Release\Symbols

Once the tool was launched, you can start inputting memory addresses, and it will output the function name (click to enlarge):



This entry was posted in Unity and tagged , , , , , . Bookmark the permalink.