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?
- Enable ADB debugging on your device
- Setting up Android Debug Bridge on your devices
- Setup Android Debug Bridge on Windows
- Setup Android Debug Bridge on Mac
- Connecting to Android Debug Bridge over Wi-Fi
- Some useful ADB commands:
- Debug app installs and updates using ADB
- Unified Endpoint Manager alternatives.
How does Android Debug Bridge work?
There are 3 basic components in ADB
- 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.
- A daemon (adbd) that runs as a background process on a device and handles the execution of received commands.
- 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
- Open the Settings app
- 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
- Tap on Advanced to reveal Developer Options.
- 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”.
Setup Android Debug Bridge on Windows
- Navigate to the location where you downloaded the ZIP file in File Explorer.
- 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.”
- Right-click the platform-tools folder that contains the ADB package while holding down the Shift key.
- Type “./adb device” in the Open PowerShell window.
- On your phone, enable USB debugging and choose Always allow from this computer.
- Re-enter the “./adb device” command, and you should see the device’s serial number.
Setup Android Debug Bridge on Mac
- Open Finder and extract the zip file to, wherever you want.
- Change the USB mode on your device and plug it into your Mac.
- Open Terminal and type the platform-tools folder’s location I.e cd /Users/[UserName]/Downloads/platform-tools. Then, type in adb devices.
- 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.
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.
- Connect your device and your computer to the same Wi-Fi network.
- Connect the device to your computer via a USB cable.
- Find the IP address of your device by using ifconfig command on the device
- Make the target device’s adb daemon listen for TCP/IP connections on port 5555
- Disconnect the USB cable from the device.
- 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.
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.
Get started with Hexnode’s Android Management solution to improve efficiency, increase productivity, save time and overhead costs of managing your corporate devices.
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