Rick
Cooper

A quick guide to Android Debug Bridge (ADB)

Rick Cooper

Apr 27, 2022

6 min read

Android debug bridge (ADB) is a tool that allows a user to communicate with their Android device. Debugging is the process that helps us detect and fix errors and bugs in software that is under development, hence debugging is an important procedure in the software development lifecycle.

ADB helps in installing and debugging programs. Through ADB you can transfer files back and forth, and use the Unix shell to conduct commands. ADB may be used to change hidden settings and set up programs that work with ADB to enable useful capabilities and improve the overall device experience.

How does Android Debug Bridge work?

There are 3 basic components in ADB

  1. A client sends commands to the connected Android device. You can invoke a client from a shell by issuing an adb command client that sends commands to the connected Android device.
  2. A daemon (adbd) that runs as a background process on a device and handles the execution of received commands.
  3. A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.

When you start an adb client, it checks to see whether there is already an adb server process running. If there isn’t one, the server process is started. When the server boots up, it binds to local TCP port 5037 and listens for instructions from adb clients—all adb clients connect with the adb server over port 5037.

The server then establishes connections to all emulator/device instances that are currently active. It looks for emulator/device instances by scanning odd-numbered ports in the 5555 to 5585 range, which is the range that emulators/devices employ. The server establishes a connection to the port where it discovers an adb daemon.

Enable ADB debugging on your device

  1. Open the Settings app
  2. Navigate to ‘About Phone’.
  3. Scroll all the way down and tap the Build Number seven times. (You will get a message saying, “You’re now a developer.”)
  4. Head back to Settings > System
  5. Tap on Advanced to reveal Developer Options.
  6. Find the option to enable USB Debugging.

Setting up Android Debug Bridge on your devices

Android Studio is the official Integrated Development Environment (IDE) for Android app development and  ADB package is already included in Android Studio under “Android SDK Platform Tools”.

If you don’t require the entire Android SDK then SDK Platform Tools package can be used to install adb.

Setup Android Debug Bridge on Windows

  1. Navigate to the location where you downloaded the ZIP file in File Explorer.
  2. Right-click the zip file and extract the contents to C:\platform-tools. Connect your device to your PC and set the USB mode to “File Transfer.”
  3. Right-click the platform-tools folder that contains the ADB package while holding down the Shift key.
  4. Type “./adb device” in the Open PowerShell window.
  5. On your phone, enable USB debugging and choose Always allow from this computer.
  6. Re-enter the “./adb device” command, and you should see the device’s serial number.

Setup Android Debug Bridge on Mac

  1. Open Finder and extract the zip file to, wherever you want.
  2. Change the USB mode on your device and plug it into your Mac.
  3. Open Terminal and type the platform-tools folder’s location I.e cd /Users/[UserName]/Downloads/platform-tools. Then, type in adb devices.
  4. Accept the “Allow USB Debugging” prompt and tap OK to always allow the connection.
  5. Re-enter the “adb device” command to see your device serial number.

Connecting to Android Debug Bridge over Wi-Fi

ADB can also be configured over Wi-Fi without the need to connect it to the USB everytime you need to use ADB functionality on your Android.

  1. Connect your device and your computer to the same Wi-Fi network.
  2. Connect the device to your computer via a USB cable.
  3. Find the IP address of your device by using ifconfig command on the device
  4. Make the target device’s adb daemon listen for TCP/IP connections on port 5555
  5. Disconnect the USB cable from the device.
  6. Connect to the device using its IP address.

Some useful ADB commands:

ADB provides a wide range of functions for the interaction between the host and the device. These functions are usually executed by typing commands in a command-line interface on the host.

Devices: Prints the list of connected devices

Help: This is helpful in finding out the commands that can be used in each device instance as this prints out the list of supported adb commands.

install: pushes an Android application to the connected device.

adb reboot: restarts your phone.

adb fastboot: Enables the fastboot mode.

adb uninstall “package name”: Uninstall an app.

start-server: Checks whether the adb server process is running and starts it, if not.

Shell: Starts a remote shell in the target device.

pull: Copies a specified file from an emulator/device instance to your development computer.

push: Copies a specified file from your development computer to an emulator/device instance.

While these are just some of the useful adb commands you can find a plethora of commands that are compatible with your device. 

Debug app installs and updates using ADB

To debug issues related to updating as well as installing apps from Managed Play, you can retrieve the Managed Play logs from a device for analysis. Android versions 4.2 and higher are capable of capturing and saving bug reports. Bug reports contain event logs that you can use to help troubleshoot issues related to app installations and updates.
Use Android Debug Bridge to get bug reports. Use logcat to view a log of system messages from all apps on the device, including Play.

Unified Endpoint Manager alternatives.

An Android device that is enrolled into a UEM simplifies some of the tasks that are done using ADB. Tasks like app installation can be remotely done in an instant from the UEM portal. Using a UEM you can get updates about the device at the click of a button. Feedback can be retrieved from Managed Google Play apps from the portal itself. The best part about this is, that once enrolled the device need not be in proximity of the computer and can be remotely managed from anywhere with an active internet connection.

An insightful guide to Android device management

Conclusion

ADB can be hard to configure and understand at first but once you get hang of the commands, it gets progressively easier to use. The ADB commands help you get better control over your Android device.

Featured resource

Hexnode Android Management Solution

Get started with Hexnode’s Android Management solution to improve efficiency, increase productivity, save time and overhead costs of managing your corporate devices.

Download datasheet

Share
Rick Cooper

Product Evangelist @ Hexnode. Millennial by age. Boomer by heart.

Share your thoughts