When an app suddenly closes or throws a mysterious error, the most reliable way to find out why is to look at its crash log. Android records a detailed stack trace for every unhandled exception, but the raw output can be overwhelming. This tutorial walks you through a repeatable workflow: enable the necessary developer settings, capture the log with adb logcat, filter for the offending app, and, if the crash involves native code, translate the addresses using Android Studio’s ndk‑stack tool.
adb) and, optionally, Android Studio if you want symbol decoding.Why this matters: USB debugging opens a communication channel between adb on your PC and the device, allowing you to pull logs in real time.
C:\adb or ~/adb).adb devices. You should see your device listed as device.
adb devices
List of devices attached
0123456789ABCDEF device
If the device shows as unauthorized, unplug and re‑plug the cable, then accept the debugging prompt again.
To capture a useful log, you need the crash to happen while adb logcat is running. Follow these steps:
com.example.app with the real package name):
adb logcat --pid=$(adb shell pidof -s com.example.app) *:E
Ctrl +C to stop logging.
adb logcat --pid=$(adb shell pidof -s com.example.app) *:E > crash_log.txt
The raw log contains many lines (system events, other apps, etc.). You need the part that starts with FATAL EXCEPTION. Use a text editor or grep to extract it:
grep -A 20 "FATAL EXCEPTION" crash_log.txt
The output will look similar to:
04-01 12:34:56.789 1234 1234 E AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.app, PID: 1234
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at com.example.app.ui.MainActivity.onCreate(MainActivity.java:45)
at android.app.Activity.performCreate(Activity.java:8000)
...
This Java stack trace tells you exactly which class and line caused the exception. If the line numbers don’t match your source code, make sure you’re looking at the same build variant (debug vs. release).
Some apps crash in native code (C/C++) and the stack trace will contain memory addresses instead of readable symbols, e.g., pc 00000000001234ab /data/app/com.example.app-1/lib/arm64/libnative.so. To translate these addresses you need the .so file and its associated .sym or .debug information.
.apk and extract the native libraries).obj/local/armeabi-v7a (or arm64-v8a) folder containing the compiled .so files.ndk-stack -sym obj/local/arm64-v8a -dump crash_log.txt
Replace the path with the folder that holds the unstripped libraries.If you don’t have the original symbol files (common for third‑party apps), you can request them from the developer or use the retrace tool with a .map file if the developer provides one.
After you’ve identified the offending line, edit the source code, rebuild the app, and repeat the capture process to confirm the crash no longer occurs. For non‑developers, you can share the extracted stack trace with the app’s support team; it gives them a concrete starting point.
adb shell ps | grep com.example.--pid filter as shown in Step 3, or add grep "com.example.app" after the log command..so files. Release builds often strip symbols; you need a debug build.sudo on Linux/macOS) or write to a folder you own.adb logcat and timestamps the file, making it easy to keep chronological records.
# Windows batch example
@echo off
set TIMESTAMP=%date:~-4,4%-%date:~4,2%-%date:~7,2%_%time:~0,2%-%time:~3,2%-%time:~6,2%
adb logcat -d > crash_%TIMESTAMP%.txt
logcat is still invaluable for reproducing the issue locally.Enabling USB debugging exposes your device to ADB commands from any connected computer. Always disconnect the phone when you’re finished, and never grant debugging access to an untrusted machine. If you suspect your device has been compromised, disable USB debugging immediately via Settings > Developer options.
By following this workflow you can turn a vague “App keeps crashing” complaint into a precise stack trace, whether the problem lies in Java code or native libraries. Armed with that information, developers can fix bugs faster and users can provide actionable feedback to support teams.









