ADB stands for Android Debug Bridge. It is a command-line tool that helps to communicate with an Android device (real or emulator) from your computer
Importance of ADB in Appium Projects
When working with Appium, we often need:
- The device name
- The app’s package name and main activity
- To install/uninstall APKs during automation
- To reset or restart the app between tests
ADB makes these tasks quick and scriptable.
How ADB Works
ADB has three components:
Client – Runs on the computer and we send commands from here.
Daemon (adbd) – Runs on the Android device and listens for commands from the computer.
Server – Manages communication between client and daemon.
Some of the Useful ADB Commands for Appium
|
Commands |
Purpose |
|
adb version |
Shows the installed ADB version. Useful for checking if it’s up to date |
|
adb devices |
Lists all connected Android devices/emulators and their status |
|
adb -s <device_id> <command> |
Runs a specific ADB command on a particular device when multiple devices/emulators are connected. |
|
adb install applicationName.apk |
Installs an APK file on the connected device. |
|
adb uninstall packageName |
Uninstalls an app from the device using its package name. |
|
adb shell pm clear <package.name> |
Clears all data and cache for the specified app (similar to “Clear data” in settings). |
|
adb shell |
Opens a Linux-like terminal session inside the connected device for running shell commands directly. |
|
adb shell ls |
Lists files and directories on the device (similar to ls in Linux). |
|
adb shell dumpsys window |
Displays system-level info about the current window and activities (often used to get app package & activity names). |
|
adb logcat |
Streams real-time system logs from the device (useful for debugging crashes or test failures). |
|
adb start-server |
Starts the ADB server (used when it’s not running). |
|
adb kill-server |
Stops the ADB server (used to reset the connection). |
|
adb usb |
Switches device connection mode back to USB after wireless debugging. |
|
adb reboot |
Reboots the connected device. |