
Essential ADB Commands for Android Development and Testing
- Alexander Wahl
- Tutorials , Development
- January 28, 2025
Table of Contents
If you work with Android devices, you’ve likely encountered ADB (Android Debug Bridge). If not, now is the perfect time to learn about this powerful tool that’s essential for Android development and testing.
What is ADB?
ADB (Android Debug Bridge) is a versatile command-line tool that lets you communicate with Android devices. It’s an essential tool for developers and QA engineers, enabling tasks like installing apps, debugging, and accessing device features directly from your computer.
Most Common ADB Commands
Here’s a collection of the most frequently used ADB commands from my QA experience:
Device Connection
# Connect to a device over network
adb connect [device_ip]
# List all connected devices
adb devices
# Restart ADB server
adb kill-server
adb start-server
# Reboot device
adb reboot
App Installation
# Install an APK
adb install [path_to_apk]
Pro tip: You can simply drag and drop the APK file into your terminal after typing adb install
to automatically fill in the path!
Screen Capture
# Take a screenshot
adb shell screencap -p /sdcard/screen.png
# Record screen
adb shell screenrecord /sdcard/video.mp4
# Press Ctrl+C to stop recording
File Management
# Copy files from device to computer
adb pull /sdcard/screen.png /Users/your_username/Desktop/
# Delete files on device
adb shell rm /sdcard/video.mp4
Debugging
# Get device logs
adb logcat -v time > log.txt
# Input text via shell
adb shell input text "your_text_here"
Installing ADB on macOS
The easiest way to install ADB on macOS is using Homebrew:
# Install Homebrew if you haven't already
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install ADB
brew install android-platform-tools
After installation, verify it’s working by running:
adb version
Installing ADB on Linux
On Linux, you can install ADB using your distribution’s package manager:
Ubuntu/Debian
# Update package list
sudo apt-get update
# Install Android tools package
sudo apt-get install android-tools-adb android-tools-fastboot
Fedora
sudo dnf install android-tools
Arch Linux
sudo pacman -S android-tools
After installation, verify it’s working by running:
adb version
Tips for Using ADB Effectively
Enable USB Debugging: On your Android device, go to Settings > Developer options and enable USB debugging. If you don’t see Developer options, go to Settings > About phone and tap Build number seven times.
Network Debugging: For wireless debugging, ensure your device and computer are on the same network. First, connect via USB and run:
adb tcpip 5555
Then you can connect wirelessly using
adb connect [device_ip]:5555
Multiple Devices: If you have multiple devices connected, specify the target device using its serial number:
adb -s [device_serial] [command]
Common Issues and Solutions
Device Not Found
If your device isn’t being recognized:
- Check USB debugging is enabled
- Try a different USB cable
- Restart ADB server:
adb kill-server adb start-server
Installation Failed
If app installation fails:
- Check if the app is already installed
- Ensure you have enough storage space
- Try uninstalling the existing version first:
adb uninstall com.package.name
Conclusion
ADB is an invaluable tool for Android development and testing. These commands represent just a fraction of what’s possible with ADB, but they cover the most common use cases you’ll encounter in day-to-day development and QA work.
Remember to keep your ADB tools updated and always ensure you’re following security best practices when using ADB, especially when connecting to devices over a network.