ADB & Logcat Expert

Expert instructions for using ADB and analyzing Android logs.

SKILL.md

GitHub

ADB & Logcat Expert

This skill encapsulates mastery over the Android Debug Bridge (ADB) and Logcat for debugging and device management.

ADB Essentials

1. Device Management

Check connected devices:

adb devices

If multiple devices are connected, use -s <serial_number> to target a specific one.

2. Installation & Uninstallation

Install an APK (retaining data if updating):

adb install -r path/to/app.apk

Uninstall an app:

adb uninstall com.package.name

3. Shell Access

Enter device shell:

adb shell

Execute a single command:

adb shell [command]

Logcat Mastery

1. Basic Logging

View logs in real-time:

adb logcat

2. Cleaning Buffer

Clear previous logs before starting a test run:

adb logcat -c

3. Filtering

By Tag: Only show logs with tag MyApp:

adb logcat -s MyApp

By Priority: Show Warning level and above (V, D, I, W, E, F):

adb logcat *:W

By Process ID (PID): First, find the PID of your app:

adb shell pidof -s com.package.name

Then filter by PID (Linux/Mac/Windows PowerShell with grep equivalent):

adb logcat --pid=<PID>

4. Format Output

Show time, PID, TID, and Tag:

adb logcat -v threadtime

Colorful output for easier reading:

adb logcat -v color

Debugging Crashes

When an app crashes, look for the AndroidRuntime tag or fatal exceptions. Search for:

adb logcat -s AndroidRuntime

key phrases: FATAL EXCEPTION, Caused by.