ADB (Android Debug Bridge)

Per Claude Code:

Setup

Install Android SDK Platform Tools and add the platform-tools folder to your system PATH (Control Panel β†’ Environment Variables β†’ Path β†’ New). Then adb works from any terminal.


Essential Commands

Device Management

adb devices                    # List connected devices
adb -s <device-id> shell       # Target a specific device

Logs

adb logcat                             # Stream all logs
adb logcat | grep "MyTag"              # Filter by tag
adb logcat -c && adb logcat            # Clear old logs then stream fresh
adb logcat > logs.txt                  # Save logs to file

App Management

adb install app.apk                    # Install an APK
adb uninstall com.example.app          # Uninstall by package name
adb shell am force-stop com.example.app  # Force-stop the app

Inspecting the Device

adb shell dumpsys alarm                         # All scheduled alarms
adb shell dumpsys alarm | grep <package>        # Filter to one app's alarms
adb shell dumpsys notification                  # All active notifications
adb shell dumpsys battery                       # Battery state
adb shell getprop ro.build.version.sdk          # Android API level

File System

adb shell ls /data/data/com.example.app/   # App's data directory
adb pull /sdcard/Download/file.txt .       # Copy file from device to current dir
adb push file.txt /sdcard/Download/        # Copy file from PC to device

Networking (Wireless ADB)

adb tcpip 5555                 # Switch device to WiFi mode (while plugged in)
adb connect 192.168.1.X:5555  # Connect over WiFi (unplug cable after this)
adb usb                        # Switch back to USB mode

Flutter Workflow

# Filter logs to Flutter and your app
adb logcat | grep "flutter\|<your-package>"

# Check scheduled alarms for your app
adb shell dumpsys alarm | grep -A 4 "<your-package>"

# Restart the app without reinstalling
adb shell am force-stop com.example.app
adb shell monkey -p com.example.app 1

Tips