When an app suddenly stops, freezes, or crashes, Android records a detailed trace in the system log. Those traces—known as logcat output—contain the exception type, stack trace, thread state, and often the exact line of code that caused the failure. Accessing that information lets you pinpoint the problem, verify whether it’s a bug in the app or a device‑specific issue, and communicate clear data to developers or support teams.
.txt log files.mapping.txt file generated when the app was built with ProGuard/R8.ADB is part of the Android SDK Platform‑Tools package. It works on Windows, macOS, and Linux.
platform-tools zip from the official Android developer site (developer.android.com).C:\adb on Windows or ~/adb on macOS/Linux.PATH so you can run adb from any terminal.
C:\adb.export PATH=$PATH:~/adb to your ~/.bashrc or ~/.zshrc and reload the shell.adb version
You should see something like Android Debug Bridge version 1.0.41.USB debugging gives ADB permission to communicate with the phone.
adb devices
The command should list a device ID followed by device. Example:
List of devices attached
R58M7XXXX device
If you see unauthorized, check the phone’s dialog and tap Allow. If the list is empty, try the following:
udev rules (Linux) or that the device appears in system_profiler SPUSBDataType (macOS).Now that ADB sees the device, you can start pulling logs.
adb logcat
This prints an endless stream of log lines.
04-12 14:23:45.678 1234 5678 E/AndroidRuntime: FATAL EXCEPTION: main
04-12 14:23:45.679 1234 5678 E/AndroidRuntime: Process: com.example.app, PID: 1234
04-12 14:23:45.680 1234 5678 E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
04-12 14:23:45.681 1234 5678 E/AndroidRuntime: at com.example.app.ui.MainActivity.onCreate(MainActivity.java:45)
Ctrl+C to stop the stream once the crash has been reproduced.
adb logcat -c before starting to clear the existing buffer. This makes the resulting file smaller and easier to read.Instead of watching the stream, you can write it directly to a file.
adb logcat -d > crash_log.txt
The -d flag tells ADB to dump the current buffer and exit. If you want a continuous capture, omit -d and redirect:
adb logcat > crash_log.txt
When you’re done, stop with Ctrl+C. Transfer the file to your PC (it’s already there if you ran the command on the PC) and open it with any text editor.
Logcat is noisy; a typical Android session generates thousands of lines per minute. Filtering helps you focus on the crash.
adb logcat *:E
Shows only entries with priority E (Error) or higher.
Most crash reports are tagged AndroidRuntime. Use:
adb logcat AndroidRuntime:E *:S
*:S silences all other tags.
If you know the app’s PID (visible in the crash lines), you can filter:
adb logcat --pid=1234
Example – show errors from the target app only:
adb logcat -v threadtime AndroidRuntime:E *:S --pid=1234
The -v threadtime format adds timestamp, PID, and TID, which is useful for correlating events.
When the app is built with code shrinking (ProGuard or R8), the stack trace shows obfuscated class and method names like a.b.c. To translate them back you need the mapping.txt file produced at build time.
mapping.txt in the app/build/outputs/mapping/release/ directory of the original APK project.retrace tool that ships with the Android SDK (found under tools/proguard/bin/retrace).retrace -verbose mapping.txt crash_log.txt > decoded_log.txt
The output replaces obfuscated symbols with the original names.
mapping.txt that matches the installed APK version, the deobfuscation will be inaccurate.If you already have Android Studio, its built‑in Logcat UI provides colour‑coded filtering, search, and the ability to copy stack traces directly.
level:error or tag:AndroidRuntime) to narrow results..txt file.Android Studio also lets you paste a stack trace into the Analyze → Analyze Stack Trace dialog, which automatically links to the source code if you have the project opened.
adb devicesSUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
adb kill-server
adb start-server
adb logcatSome manufacturers (e.g., Xiaomi, Huawei) add a secondary “Log access” toggle under Developer options. Enable it. If the device still blocks access, you may need to grant the android.permission.READ_LOGS permission, which is only available to system apps—so on stock devices you’re limited to your own app’s logs. In that case, use adb shell setprop log.tag.YOUR_TAG DEBUG to increase verbosity for your own tags.
If you capture logs for a long period, the circular buffer may overwrite older lines before you can save them. To avoid loss:
adb logcat -c.
Some crashes are caught by the system and reported only as a short “App has stopped” toast. In those cases, enable the “Show system” filter in Logcat or use adb shell dumpsys activity crashes to retrieve the last crash report.
adb logcat -c each time you begin a new test to avoid mixing old entries.Log.e("MyFeature", "Something went wrong", e) so you can filter by MyFeature later.logcat, run adb shell dumpsys battery, adb shell dumpsys meminfo, and adb shell getprop to collect context that may influence the crash.Logcat records everything that apps write to the system log, including potentially sensitive information such as API keys, user identifiers, or location data. Treat logs as confidential:
After you have a clear stack trace and, if applicable, a deobfuscated version, you can provide the developer with:
logcat excerpt (use adb logcat -d AndroidRuntime:E *:S).
This information often lets developers locate the offending line of code within minutes.
Capturing and analyzing Android crash logs with ADB and Logcat is a powerful, no‑root method for troubleshooting app failures. By installing ADB, enabling USB debugging, clearing the log buffer, reproducing the crash, and then filtering or deobfuscating the output, you gain a clear view into what the system saw at the moment of failure. The workflow described here works across manufacturers and Android versions, and the added troubleshooting tips help you overcome the most common obstacles.
Armed with these logs, you can either fix the issue yourself (if you’re a developer) or provide developers with the exact data they need to issue a fix. Remember to handle logs responsibly, keep your debugging tools up to date, and disable USB debugging when you’re done.









