Android Debug Bridge (ADB) is a command-line tool that is integrated with the Android SDK. You can use it to communicate with a device and perform various actions, such as installing and debugging apps, copying files back and forth, and accessing the Unix shell to execute commands.
You can use ADB to tweak hidden settings, set up apps in conjunction with ADB to enable powerful features, and improve the overall device experience. We’ll show you how to set up ADB and learn key shell commands to perform useful actions.
What is Android Debug Bridge (ADB)?
The internal structure of Android Debug Bridge (ADB) is based on the classic client-server architecture. There are three components that make up the entire process.
The client, which is the PC or Mac that you have connected to your Android device. We send commands from this computer to our device via the USB cable (and in some cases wirelessly).
A daemon (adbd) that executes commands on a device. The daemon runs as a background process on each device.
A server that manages the communication between the client and the daemon. The server runs as a background process on the PC/Mac.
How does ADB work?
Since there are three parts that make up ADB (the client, the daemon, and the server), this requires certain parts to be operational in the first place. So, if you have rebooted the computer (and you haven’t set it up to start the daemon at boot time), you will need to run it before any communication can be sent to the target Android device. You will see the following message at the command prompt or in the terminal as it verifies that the daemon is running.
If the daemon is not running, it starts the process and tells you on which local TCP port it was started. Once this ADB service is started, it continues to listen to that particular port for commands sent by the ADB client. It then makes connections to all running devices connected to the computer (including emulators). This is the moment when you receive the authorization request on the Android device if the computer has not been authorized in the past.
To set up ADB
- Launch the Settings application on your phone.
- In general, tap the About phone option at the bottom of the list.
- Then tap the Build number option seven times to enable developer mode. You will see a toast message when it is ready.
- Now go back to the main Settings screen and you should see a new Developer Options menu that you can access.
- Go in there and enable the USB debugging mode option.
- You are partially done with setting up the phone. Next, you need to scroll down and follow the rest of the instructions for your particular operating system.
Examples of ADB commands
To verify that you have successfully installed ADB, connect your device to your PC/Mac with your USB cable and run the adb devices command as described above. It should show your device listed in the Command Prompt/PowerShell/Terminal window. If you get a different output, we recommend starting over with the steps.
As mentioned above, you can use ADB to do all sorts of things on an Android device. Some of these commands are built right into the ADB binary and should work on all devices. You can also open what is called an ADB shell, which allows you to run commands directly on the device. The commands that are executed directly on the device can vary from device to device (as OEMs can remove access to certain commands and also change adb behavior) and can also vary from one Android version to the next.
Below is a list of sample commands that you can run on your device:
- Print a list of connected devices: adb-devices.
- Kill the ADB server: adb kill-server
- Install an application: adb install
- Set up port forwarding: adb forward tcp:6100 tcp:7100
- Copy a file/directory from the device: adb pull
- Copy a file/directory to the device: adb push
- Initiate an ADB shell: adb shell