Android Debug Bridge (ADB) is a command-line tool built into Android’s SDK. It lets you communicate with a device and perform various actions, such as installing and debugging apps, copying files back and forth, and accessing Unix shell to run commands.
You can use ADB to tweak hidden settings, set up apps in conjunction with ADB to enable powerful features, and enhance the overall device experience. We’ll show you how to set up ADB and learn important shell commands to perform useful actions.
How ADB Works
ADB is a client-server program that includes three components:
Client: The client run adb commands from a shell or script on your development machine. Its role is to send commands to the server.
Daemon (adbd): The daemon runs as a background process on your device. Its purpose is to connect with the ADB server through USB or TCP for emulators. The ADB server consider a device “online” when it successfully connect with the daemon.
Server: The server runs as a background process on your development machine. Its purpose is to sense the USB port when you attach or remove the device, maintain a list of connected devices, and assign different states to each of them like “online,” “offline,” “bootloader,” and “recovery.”
When you invoke the “adb” command, the client will first check if the adb server is running or not. If not, the server tries to connect with the daemon until it finds them. Once it does, you’ll receive the authorization request on your device and bind it to the local TCP port. From here onwards, it will continue to listen to that specific port for commands.
Setting up ADB on Your Devices
ADB package is already included in the “Android SDK Platform Tools” built into the Android Studio. If you’re a casual user or just getting started with the ADB, you don’t need to install an IDE. Head to the Android SDK Platform Tools and select the link for your operating system.
Since Google periodically updates the platform tools, there are chances that something may go wrong while upgrading it. We recommend using a package manager to automatically update the ADB and set the Environment Variable (on Windows) or PATH (on Mac) for you. Here’s our guide on how to set up and use Chocolatey for Windows and Homebrew for Mac to manage ADB.
Enable USB Debugging on Android
Open the Settings app and navigate to About Phone. Scroll all the way down and tap the Build Number seven times. You will get a message saying, “you’re now a developer.” Head back to Settings > System, then tap Advanced to reveal Developer Options. In here, enable USB Debugging.
At surface level, USB Debugging enables your device to communicate with a computer that’s running Android SDK. To know more, read our guide on how USB Debugging mode works in Android.
Setup ADB on Windows
Open File Explorer and browse to the location where you saved the ZIP file. Right-click and extract the contents of the zip file to C:\platform-tools. Plug your device into the PC and change the USB mode to “File Transfer” mode. Some OEMs may or may not require this, you may leave it in this mode for compatibility.
Press and hold the Shift key and right-click the platform-tools folder that contains the ADB package. Choose Open PowerShell window here.
Then, type in
./adb devices
Note: In PowerShell, make sure to put the dot-forward slash before the “adb devices” command. You’ll not need to insert dot-forward slash if you’re using CMD.
On your device, you’ll see a prompt with a message saying Allow USB Debugging on your phone. Check the Always allow from this computer and tap OK. Re-enter the “./adb device” command, and if everything is successful, you’ll see the device’s serial number.
While the above procedure will work, your Android device may sometimes fail to connect over the ADB. Consult our guide on steps you can take to fix the ADB connection in a Windows PC.
Setup ADB on Mac
Open Finder and extract the zip file to your preferred location, either Desktop or Downloads. Plug your device into the Mac and change the USB mode. Open Terminal and type in the path of the platform-tools folder
cd /Users/[UserName]/Downloads/platform-tools
Then, type in
adb devices
On your device, accept the “Allow USB Debugging” prompt and tap OK to always allow the connection. Re-enter the “adb device” command to see your device serial number.
Setup ADB Wirelessly with Android
Setting up ADB over USB is seamless and requires a complex procedure. But, there are some disadvantages of using this method. First, the number of devices you can plug-in depend on the available ports. Second, there could be an issue with the driver compatibility.
You can remove these complications while setting up ADB over Wi-Fi. This method is possible using ADB’s “tcpip” and “connect” commands to help you use the device wirelessly. But to execute these commands, your device should be plugged via USB.
If you’re on Android 11 (with SDK platform tool version 30 or greater) and above, you can use wireless debugging to pair your device with the computer. This method uses a new command called “pair” and works similar to Bluetooth pairing.
Head to Settings > Developer Options > Enable Wireless Debugging. Select Pair device with pairing code. Take note of the pairing code, IP address, and port number.
Follow the procedure as above, then type in
adb pair ipaddr:port
Replace “ipaddr” with the IP address and “port” with the port number. When prompted, enter the pairing code you received previously. If everything is successful, you’ll see a message that your device is paired.
Useful ADB Commands
There’s a lot ADB can do, and in most cases, it’s useful for both casual users and developers. Here is a list of commands that you may find useful. The inverted commas used in the commands are just for illustration purposes.
- adb devices: Shows which ADB supported devices are connected to your computer.
- adb reboot: restarts your phone.
- adb install “path_to_apk”: Install an app.
- adb pull “remote local”: Copy a file and its sub-directories from the device. Replace local/remote with the paths to the target file/directory on your machine (local) and on device (remote).
- adb push “local remote”: Copy a file and its sub-directories to the device.
- adb kill-server: Terminate the adb server process and restart it.
- adb fastboot: Enables the fastboot mode.
- adb help: Displays the help documentation of ADB commands.
- adb uninstall “package name”: Uninstall an app.
List All the Android Packages:
adb shell pm list packages
Print the list of packages. Type in “-d” to show only disabled packages, “-e” to show only enabled packages, “-s” to show only system packages.
Remove Unwanted Pre-Installed Apps:
adb shell pm uninstall -k --user 0 <package name>
With this command, you can uninstall pre-installed apps without rooting your device. Package name refers to the name of the .apk file. You can use a free app called App Inspector to find the package name.
List App Components:
An app’s components are things like its activities, services, and more. With this command, you can launch hidden activities or send a broadcast with specific data.
adb shell dumpsys package <package name>
See the list of activities under Activity Resolver Table and Service Resolver Table for services.
Try These ADB Apps to Enable Powerful Features
At first glance, the setup procedure seems complicated—but it isn’t hard. You need to follow the steps sequentially and note any errors. Since now you know about ADB commands, try these apps and configure ADB to get more control over your Android device.