You can learn what is Android Debug Bridge (ADB) with this article. Our intention is not to go into much depth, but simply to show how to get it working on Windows and Linux and some things that can be done with it. In other words, it is more of an introductory material than an advanced technical tutorial, although it is true that it can be a bit difficult if you don’t have some previous knowledge on how to deal with a command console.
What is Android Debug Bridge (ADB)?
In a nutshell and for simplicity, ADB is a command-line tool that allows a Windows, Linux, or Mac computer to communicate with an Android device. It allows a variety of actions to be performed on the Android device, including sending files from the computer, copying files present on the Android device, debugging applications, installing and uninstalling packages, and providing access to a Unix shell.
It also allows you to reboot an Android device in a standard way, in recovery mode (recovery), the bootloader (bootloader), or by performing a previous sideloading process (transferring files between two local devices, which is usually done when you want to change the manufacturer’s Android for a custom ROM), as well as performing many other actions.
As we can see, ADB is quite versatile, although, at least with Google’s official tools, it requires minimum knowledge of command lines to use it.
How to download and run the Android SDK for Windows?
The logical thing to do is to access the Android developer website, but on its home page what is made available by default is not the bare SDK, but the entire stack for application development through the official Integrated Development Environment (IDE): Android Studio.
Android Studio is based on JetBrains technology and is a very capable IDE, but it deviates from the purpose of this introductory tutorial by serving far, far more than necessary. Alternatively, we will download the “bare” SDK, which can be obtained via the following path:
Then the terms and conditions of use will appear, which the user will have to accept if he wants to start downloading the Android SDK (it seems that at the moment the web has a bug).
Once the ZIP file has been downloaded, access the ‘platform-tools’ subdirectory that should have appeared (in case of performing the extraction process with Windows tools, you may have to go down one more sublevel) after unzipping it, press the key combination ‘ctrl+L’ and copy the path that appears as selected text.
After copying the path from Windows 10 File Explorer, proceed to open a PowerShell console and type the following, but without pressing enter:
- cd “”
After typing the “skeleton” of the command, paste the path obtained from Windows File Explorer between the quotation marks. It is important to note that “Guillermo Puertas” is the user used for this tutorial, so this may change. The use of quotation marks is to avoid spaces cutting the command.
- cd “C:\Users User User Download Platform Tools”.
To check if ADB is available, just run it with the help argument and see if it shows up or if you get some kind of error.
- .\adb –help
Modifying the user’s PATH in Windows
As getting the path where the Android SDK is located over and over again ends up becoming tiresome, as an alternative you can add its location to the user’s PATH. To do this you have to open the advanced system settings of Windows 10.
In the window that appears, whose title is “System Properties”, proceed to click on the “Environment Variables” button located at the bottom of “Advanced Options”.
In “User variables for YOUR USER” (Guillermo Puertas in our case) you have to select the ‘Path’ variable and click on the “Edit” button.
Finally, the user must click on the “New” button, paste the path where the Android SDK is located in a new line, click on the enter key, click on the “OK” buttons of the “Edit environment variable” and “Environment variables” windows and close everything to perform a system restart.
After following all these steps, the user should be able to use ADB right after opening the PowerShell console, so instead of having to type this:
- \Ò.adb.
You can directly enter the following:
- adb
How to get ADB on Linux?
Obtaining ADB on Linux, if you resort to the repositories of the distributions, is simpler than on Windows. All you have to do is install the package containing the Android SDK tools. The fact that you are using the command line also simplifies the process.
Package to install on Ubuntu 20.04 LTS (and possibly later versions) and Debian 11 Bullseye:
- sudo apt install android-sdk
In case the installation gives problems, it is likely to be solved with the following command:
- sudo apt –fix-broken install
Package to install on Fedora Workstation:
- sudo dnf install android-tools
Package to install on Fedora Silverblue and Kinoite (in this case it is necessary to reboot):
- rpm-ostree install android-tools
Package to install on Manjaro (where it may be pre-installed) and Arch Linux:
- sudo pacman -S android-tools
After installing the corresponding package, ADB should already work in an integrated way in the PATH of the system, without any further configuration. To check this, just show the help.
- adb –help
“Bonus track for Linux users
In the case of trying to reboot the mobile in ‘bootloader’ or ‘recovery’ mode with ADB from Linux, the user may find that it does not have sufficient permissions to act. This is fixed by adding a udev rule for the Android device in use.
First, connect the Android device via USB and run the following command:
- lsusb
In our case, the connected smartphone has been recognized as if it were a Google Nexus or Pixel device, despite actually being a POCO X3 PRO. From the line corresponding to the smartphone we copy the first part of the identifier, the one to the left of the colon in the sixth column.
Then you have to open or create the following file with a plain text editor and administrator permissions. In our case, we mention Gedit because it is graphical and preinstalled in Ubuntu, but the user can use Nano, Vim, or whatever he wants:
- sudo gedit /etc/udev/rules.d/51-android.rules
Enter the following line in the file, but change the identifier to that of the Android device connected to the user’s computer.
- SUBSYSTEM==”usb”, ATTR{idVendor}==”IDDISPOSITIVE”, MODE=”0666″, GROUP=”plugdev”
After entering the rule, proceed to save the changes, close the file reboot the system to take effect, and reboot an Android device in bootloader or recovery mode.
Enabling developer mode and USB debugging on an Android device
To make use of ADB you need to start developer mode and enable Android USB debugging. The steps are essentially the same on all mobiles and tablets that make use of Google’s operating system, but their order may vary because its Open Source nature allows for major modifications. In our case, we have used a POCO X3 PRO, which follows the lines marked by Xiaomi.
The first step is to open the System Settings and click on “About phone”.
The second step is to press seven times (or as many as it takes) on the version of the operating system to activate the developer mode, which in our case is the version of MIUI for POCO.
With the developer mode already activated, it’s time to enable USB debugging. To do this you have to go back to the main Settings screen and go to Additional settings > Developer options > USB debugging.
After flipping the switch to enable USB debugging, a confirmation screen will appear that the user must fill incorrectly.
Upon connecting the Android device via USB the fingerprint should appear to enable USB debugging. The answer to the question must be yes.
After following all these steps you should be able to proceed to use Android Debug Bridge.
How to use ADB?
Making basic use of ADB (remember that this is an introductory tutorial) is easy if you have some notions of how to use a command line. From here we will assume that the Windows user has added the Android SDK to his PATH. In case he has not done so, at the beginning of the commands, instead of ‘and’ you have to put ‘.adb’, in addition to having to access first via the command line to the location where the Android SDK is located.
To display the connected Android devices, the command to execute is as follows:
- adb devices
Although there are easier ways to do this thanks to the fact that the user’s directory subtree in Android can be mounted as a storage unit, it is possible to send a file from the computer with the ‘push’ argument. ‘screen1.png’ is the file located on the computer that you want to send to the POCO mobile, while ‘/storage/self/primary’ is the root of the user’s internal storage. It is important to note that, at least initially, you cannot send a file to just any Android subdirectory due to permissions issues.
- adb push screen1.png ‘/storage/self/primary’
The ‘pull’ argument allows getting a file stored on the Android device. In this case, we have downloaded a document about the AMD IBS features located in the ‘Download’ folder, which is located just below the root of the user’s internal storage.
- adb pull ‘/storage/self/primary/Download/AMD_IBS_paper_EN.pdf’.
To reboot an Android device in the standard way with ADB you run the following:
- adb reboot
To reboot in ‘recovery’ mode the command is this:
- adb reboot recovery
And the following to reboot in ‘bootloader’ mode:
- adb reboot bootloader
To access the ADB Unix shell you have to enter the following:
- adb shell
If the user sees that ADB is not working properly, a possible solution is to kill the server and restart it:
- adb kill-server
- adb start-server
Conclusion
So much for the basics of ADB. In the inkwell, we have left ‘fastboot’, another very interesting tool whose use is essential if you want to change the Android preinstalled by the manufacturer for a third-party ROM as LineageOS.
Despite everything, we hope that this tutorial will serve to start to get an idea of the possibilities offered by Android (or rather its ecosystem of tools) through the command line because you know, knowledge is power, and the more knowledge the user has, the freer he will be when deciding on the devices he uses. And as the movement is demonstrated by walking you can check our guide: How to install a custom Android ROM and take advantage of its benefits.