Automate ADB commands for device management, app installation, and log analysis. Use when listing devices, installing APKs, viewing logs, debugging app issues, or capturing screenshots.
日本語に翻訳
name: android-adb
description: Automate ADB commands for device management, app installation, and log analysis. Use when listing devices, installing APKs, viewing logs, debugging app issues, or capturing screenshots.
license: MIT
version: 1.0.0
Android ADB Skill
Automate ADB commands for device management, app installation, and log analysis.
When to Use
Listing connected devices
Installing/uninstalling APKs
Viewing application logs
Debugging app issues
Capturing screenshots/screen recordings
Commands
Device Management
Command Description ADB Command devicesList connected devices adb devices -lrestartRestart ADB server adb kill-server && adb start-server
App Management
Command Description ADB Command installInstall APK adb install -r app.apkuninstallRemove app adb uninstall com.package.nameclearClear app data adb shell pm clear com.package.namestartLaunch app adb shell am start -n pkg/.ActivitystopForce stop app adb shell am force-stop com.package.name
Logcat Commands
Command Description ADB Command logView all logs adb logcat -v threadtimelog:appApp logs only adb logcat --pid=$(adb shell pidof pkg)log:tagFilter by tag adb logcat -s TAG_NAMElog:errorErrors only adb logcat *:Elog:clearClear log buffer adb logcat -c
Debug Commands
Command Description ADB Command screenshotCapture screen adb exec-out screencap -p > screen.pngscreenrecordRecord screen adb shell screenrecord /sdcard/video.mp4anrCheck ANR traces adb pull /data/anr/traces.txtcrashGet crash logs adb logcat -b crash
Logcat Patterns
# Filter by specific tags (common managers)
adb logcat -s GameManagerImpl AuthService SyncManager
# Compose errors
adb logcat | grep -i "compose\|recomposition"
# Coroutine exceptions
adb logcat | grep "CoroutineException\|JobCancellationException"
# ANR detection
adb logcat | grep -i "ANR\|Application Not Responding"
# Timber logs (class name as tag)
adb logcat | grep -E "(GameManager|UserManager|AuthService)"
Usage Examples
# Install and launch debug build
adb install -r app/build/outputs/apk/debug/app-debug.apk
adb shell am start -n com.creative.aiquiz/.LauncherActivity
# Clear app data and restart
adb shell pm clear com.creative.aiquiz
adb shell am start -n com.creative.aiquiz/.LauncherActivity
# Monitor specific logs
adb logcat -s GameManagerImpl:V
# Capture crash on error
adb logcat *:E -d > crash_log.txt
# Take screenshot for bug report
adb exec-out screencap -p > screenshot.png
Error Handling
# Check device connection
adb devices -l || (adb kill-server && adb start-server && adb devices -l)
# Handle installation errors
adb install -r app.apk 2>&1 | grep -q "INSTALL_FAILED" && {
echo "Installation failed - checking signature..."
adb uninstall com.package.name
adb install app.apk
}
# Parse crash from logcat
adb logcat -b crash -d | grep -A 20 "FATAL EXCEPTION"
Common Errors:
Device not found : Enable USB debugging in Developer Options
Installation failed : Uninstall conflicting version first
Permission denied : Device needs root or debugging enabled
Unauthorized : Approve computer on device prompt
Troubleshooting
Issue Command Device offline adb kill-server && adb start-serverMultiple devices adb -s SERIAL_NUMBER shellApp not starting adb shell am start -D -n pkg/.ActivityScreen frozen adb shell input keyevent 26Storage full adb shell df -h
Command Workflows
# Full debug cycle
adb logcat -c && \
./gradlew installDebug && \
adb shell am start -n com.pkg/.MainActivity && \
adb logcat -s MainActivity:V
# Capture crash report
adb logcat -b crash -d > crash.txt && \
adb bugreport > bugreport.zip
# Monitor specific feature
adb logcat -c && adb logcat -s GameManager AuthService SyncManager
CI/CD Integration
# Firebase Test Lab
- name: Run Instrumented Tests
run: |
gcloud firebase test android run \
--type instrumentation \
--app app-debug.apk \
--test app-debug-androidTest.apk
Best Practices
Prefer filtered logs to avoid overwhelming output
Use -d flag to dump existing logs and exit
Clear logcat before reproducing issues
Use Timber tags consistently (class name)
References