It has been quite a long time since our readers have been asking us what is ADB and how can they get it working on their computer. I’ve been postponing the idea of writing this guide but luckily it struck my mind today and now in this post I will be explaining you:
What is ADB?
ADB stands for Android Debug Bridge which is a part of the Android SDK package. According to Google:
Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components:
- A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
- 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.
- A daemon, which runs as a background process on each emulator or device instance.
If that was confusing, let me make it easier for you. I’m not sure how many of you know about the Terminal Emulator app for Android. It is an app that lets you execute ADB commands on your phone. But in some cases, you can not always use the Terminal Emulator app on your phone and hence you need to execute those commands on your computer which communicates with your phone while the ADB server runs in the background. To see if the server is running, you can open up your computer’s task manager and look for adb.exe. The phone (known as daemon) must be connected to the PC via USB cable with USB Debugging on. Enabling USB Debugging makes sure your PC can communicate to the phone via the USB Server.
The image below may give you a better understanding. If not, you will know when you read why you should use it.
Why Should You Install ADB on Your PC?
ADB commands are executed usually when you carry out some hacking activity on your phone. For instance, if you wish to flash a recovery image to your phone (custom recovery or CWM) you need to execute an ADB command to flash the image to your device. That makes it quite easy. You may find a few tools that claim to automatically install recovery on your device with a single click. Basically, the tool uses a .bat file which executes the ADB command automatically. The ADB server (ADB.exe file) is included in the folder where the .bat file exists. Once you run the .bat file, it issues a command to start the ADB server and executes the command to flash the recovery image to your device.
You may also need to execute fastboot commands when your phone is booted into the fastboot mode. These commands are usually used to unlock bootloaders. You can find all these commands in the last section of this post.
How to Install ADB on your Computer?
ADB is a part of the standard Android SDK. You can download it from here. You need to install Android SDK on your PC in order to execute ADB commands. The SDK package you downloaded is not the complete development environment that you would need. It only has the core SDK tools, which you can use to download the rest of the SDK packages.
Android SDK is available as an installer package (.exe file). Install Android SDK on your computer in the location C:\ You may also install it C:\Program Files\ or any location in the C: drive you wish to.
Once you have installed Android SDK, you need to open the folder where you have installed it. For example, let us consider it as C:\Android-SDK-Windows\ folder. Within this folder you will find a file known as “SDK Manager.exe” Run this file to get the list of packages available for download.
You do not need to download all of the packages given in the list. Uncheck everything first and then check only the packages under “Tools” which are Android SDK Tools and Android SDK Platform tools. After this click on “install packages”. After you have installed the packages, you will see “Installed” written next to their names.
How To Use ADB?
The usage of ADB is quite simple and does not require you to be a coding expert or anything similar. As already mentioned, you will need ADB commands to flash recovery images or to unlock bootloaders of your device.
If you are flashing a recovery image or pushing a file to your phone, you need to move the file to the platform tools folder where adb.exe is located. After you do this, you need to open Command Prompt and change the directory to the platform-tools folder. You can do it by going to the folder, and press Shift + Right click and then choose “Open Command Prompt here” option. This is possible if you are on Windows 7. Alternatively, you can use the command “cd [full path to platform-tools folder]”. After this you can flash the recovery image or push any file to your phone by entering the respective command.
Frequently Used ADB Commands
Now I will tell you a few adb commands that you might often use . Before you execute these commands, you should connect your phone to the PC via USB cable and make sure USB Debugging is checked on your phone. Also make sure you have changed the directory to platform-tools folder as mentioned above.
adb devices // This verifies that your phone is connected to the PC and displays the serial number of your phone
On executing the command if you see a line that says “No device found” you should perhaps check the device drivers of your computer. If you do not have them installed, ADB server will not recognize your phone.
adb reboot //Reboots your device
adb reboot recovery //Boot device into recovery
adb reboot bootloader //Boot device into bootloader mode (white screen with the android on wheels)
adb shell //this will shell into the phone and you can now explore the phone using linux commands
adb remount //remounts the system partition on the phone so you can you read/write to it
adb push xxx yyy //will push xxx file from computer into yyy location/file on phone (needs rooted access)
adb pull xxx yyy //will pull xxx file from phone into yyy location/file on computer (needs rooted access)
These were some ADB commands. Let us now have a look at some fastboot commands. Fastboot is protocol used to update the flash filesystem in Android devices from a host over USB. It allows flashing of unsigned partition images.
fastboot oem unlock //this will unlock your bootloader
fastboot erase XXX //This will erase the partition XXX (such as userdata, cache) - mainly used for resetting phone and clearing userdata / factory settings
fastboot flash XXX YYY //This will flash XXX partitionn with YYY image
Hopefully this guide and the commands mentioned above will help you in hacking your android device in a better and easy way. If you face any issues or have any questions, feel free to comment below 🙂