ADB (Android Debug Bridge) is a command-line tool that lets you communicate with an Android device or emulator. Whether you're pushing files, reading logs, running shell commands, or installing apps, ADB is the tool you'll reach for constantly in Android development and AOSP work.
How ADB Works
ADB Architecture
Your Computer Android Device
┌───────────────┐ ┌───────────────┐
│ adb client │ USB / TCP │ adbd │
│ (your shell) │◄────────────►│ (adb daemon) │
└───────┬───────┘ └───────────────┘
│
┌───────▼───────┐
│ adb server │ ← runs on your machine (port 5037)
│ │ ← manages device connections
└───────────────┘The ADB client (your shell) talks to the ADB server running locally on port 5037. The server manages connections to one or more devices, each running adbd (ADB daemon). Communication happens over USB or TCP/IP.
Essential ADB Commands
- ▸adb devices - list connected devices
- ▸adb shell - open an interactive shell on the device
- ▸adb logcat - stream device logs (use -s tag to filter by tag)
- ▸adb push <local> <remote> - copy file to device
- ▸adb pull <remote> <local> - copy file from device
- ▸adb install app.apk - install an APK
- ▸adb reboot - reboot the device
- ▸adb reboot bootloader - reboot to fastboot mode
- ▸adb reboot recovery - reboot to recovery
- ▸adb root - restart adbd with root privileges (AOSP / debug builds only)
Useful ADB Shell Commands
- ▸adb shell dumpsys <service> - dump state of a system service (e.g. dumpsys activity, dumpsys battery)
- ▸adb shell getprop - list all system properties
- ▸adb shell setprop <key> <value> - set a system property
- ▸adb shell pm list packages - list all installed packages
- ▸adb shell am start -n com.pkg/.Activity - launch an activity
- ▸adb shell input tap <x> <y> - simulate a screen tap
- ▸adb shell screencap /sdcard/screen.png - take a screenshot
ADB Over Wi-Fi (Wireless)
- ▸Android 11+: In Developer Options, enable 'Wireless debugging', scan the QR code with 'adb pair'
- ▸Older: Connect via USB first, run 'adb tcpip 5555', then 'adb connect <device-ip>:5555', unplug USB
Tip: Use 'adb -s <serial>' to target a specific device when multiple are connected. Get serials from 'adb devices'. Alias it in your shell profile for convenience.