How to Symbolicate Android Native Crash Logs Locally?

How to Symbolicate Android Native Crash Logs Locally
====================================================

To symbolicate native crash logs on Android, ensure that the following tools are installed on your machine:

Android NDK (Native Development Kit) – for the ndk-stack tool
ADB (Android Debug Bridge) – to capture device logs

Prerequisites
-------------

Android SDK installed
Android NDK installed (version used during the app build is recommended)
Access to the debug symbols (.so files) corresponding to the app release

---

Step 1: Capture the Crash Log
-----------------------------

Use ADB to collect the device logs and save them to a text file:

adb logcat -d > your_crashlog_filename.txt

> Note:
> Ensure that the native crash has already occurred before running this command, or reproduce the crash and re‑run the command immediately afterward.

---

Step 2: Obtain the Debug Symbols
--------------------------------

Locate the debug symbols ZIP file that was shipped with the release package.

1. Extract the ZIP file.
2. Identify the correct ABI directory based on the device architecture:
arm64-v8a
armeabi-v7a
3. Copy the path to the directory containing the relevant .so files.

> Important:
> The architecture of the symbols must match the architecture of the device where the crash occurred.

---

Step 3: Run the ndk-stack Tool
--------------------------------

Use the ndk-stack tool to symbolicate the crash log:

/ndk/24.0.8215888/ndk-stack

-sym

-dump

### Example

~/Android/sdk/ndk/24.0.8215888/ndk-stack

-sym ~/symbols/arm64-v8a

-dump ~/logs/native_crash.txt

---

Output
------

The output will display a symbolicated stack trace, including:

Function names
Source files
Line numbers (if available)

This information can be used to identify the exact cause of the native crash.

---

Common Issues and Tips
----------------------

Ensure the NDK version matches or is compatible with the build used to generate the symbols.
Verify that the .so files are unstripped and contain debug symbols.
* If no symbols appear, confirm that:
+ The correct ABI was used
+ The crash log contains native backtrace information (#00, #01, etc.)