
What is Android Debug Bridge (ADB)?
The internal structure of the Android Debug Bridge (ADB) is based on the classic client-server architecture. There are three components that make up the whole process.
- A client, that is, a PC or Mac that you have connected to an Android device. We send commands from this computer to our device using a USB cable (and in some cases wirelessly).
- A daemon (adbd) that executes commands on a device. The daemon runs as a background process on any device.
- A server that manages communication between a client and a daemon. The server runs as a background process on a PC / Mac.
How does ADB work?
Since the ADB consists of three parts (client, daemon, and server), certain parts must come first. So, if you've restarted your computer (and haven't set it up to start the daemon on startup), you'll need to start it before you can send traffic to the target Android device.
The following message is displayed on the command line or in Terminal while verifying that the daemon is running.
If the daemon is not running, it starts the process and tells you on which local TCP port it was started. Once started, this ADB service will continue to listen for commands sent by the ADB client on that particular port.
It then connects to all active devices connected to the computer (including emulators). In this case, you will receive an authentication request on your Android device if your computer has not previously been authorized.
How to Run ADB
First you have to do a few settings on the phone. Activate Developer options by tapping 7x on the About Phone menu. Then enable USB Debugging in the Developer options menu.
ADB Settings in Windows
- Download Android SDK Platform Tools for windows version. Extract it and place it in an easily accessible location, such as C:\platform-tools.
- Open Windows Explorer and navigate to the location where you extracted the contents of this ZIP file.
- Then open a command prompt from the same directory as this ADB binary. This can be done by holding down the Shift key and right-clicking on the folder and then clicking "Open Command Window Here". (Some Windows 10 users may see "PowerShell" instead of "Command window.")
- Connect your smartphone or tablet to your computer using a USB cable. Change the USB mode to the "File Transfer (MTP)" mode. Some OEMs may or may not need this, but for general compatibility it is best to leave this mode in place.
- In the command prompt window, start the following ADB daemon: adb devices.
- You will be prompted on your phone screen to enable or disable USB troubleshooting. Of course, you'll want to allow access to USB debugging when prompted (and if you never want to see that prompt again, click the Always allow check box).
Some ADB Commands
To check if you have ADB installed, connect the device to your PC / Mac with a USB cable and run the adb devices command as described above.
Your device should appear in the Command Prompt / PowerShell / Terminal window. If you get a different output, we recommend starting the steps again.
You can use ADB to do a variety of things on your Android device. Some of these commands are built right into the ADB binary and should work on all devices.
You can also open what is known as the ADB shell, with which you can execute commands directly on the device. Commands executed directly on the device can vary from device to device (as OEMs can remove access to certain ones and also change ADB behavior) and can also vary from one Android version to another.
- Print a list of connected devices: adb devices
- Kill the ADB server: adb kill-server
- Install an application: adb install (path_to_the_APK_file)
- Set up port forwarding: adb forward tcp:6100 tcp:7100
- Copy a file/directory from the device: adb pull (path_to_the_remote_object) (path_to_the_local_destination)
- Copy a file/directory to the device: adb push (path_to_the_local_object) (path_to_the_remote_destination)
- Initiate an ADB shell: adb shell
Comments
Post a Comment
Berilah Komentar Untuk Mendukung Blog Ini