In the Android development environment, ADB is our most Frequently used debugging tool, and its use is of course what our Android developers have to master.
1. ADB
Overview
Android Debug Bridge,android Debug Bridge, abbreviated as ADB, is a universal tool for managing emulator or real state, using the client-server model, consisting of three parts:
(1) The client part, which runs on the development computer, can run the ADB command on the command line to invoke the client, and an Android tool such as the ADB plugin and DDMS can also invoke the ADB client.
(2) The server section is a background process running on a development computer that manages the client to communicate with the daemon running in the emulator or the real machine.
(3) Daemon part, running in the background of the simulator or mobile phone.
The Adb.exe tool can be found under the <sdk>/platform-tools/directory.
When the ADB client is started, the client first detects whether the ADB server process is running and, if not, starts the server. When the server starts, it binds to the local TCP 5037 port and listens for commands sent from the ADB client-all ADB clients communicate with the ADB server using port 5037.
Next, the server is connected to all running emulators or phones. It searches for an emulator or phone by scanning an odd number port between 5555-5585, and once the ADB daemon is discovered, it connects through this port. It is necessary to note that each simulator or phone uses a pair of ordered ports, an even number port for the console connection, an odd number port for the ADB connection, for example:
Emulator 1, console:5554
Emulator 1, adb:5555
Emulator 2, console:5556
Emulator 2, adb:5557 ...
That is, if the emulator is connected to ADB on port 5555, its connection to the console is 5554 ports.
When the server is connected to all the emulators, it can be controlled or accessed using the ADB command. Because the server manages the connection and can receive commands from multiple ADB clients, any emulator or mobile device can be controlled from any client or script.
2. Enable ADB to debug
In order to carry out the ADB debugging of the mobile phone, it is necessary to connect the phone via USB to the development computer, then "USB Debug" under "System Settings" and "developer Options" of the phone.
Cond...
3. ADB command Syntax
The use of the ADB command from the command line or script file of the development computer is :
adb [-d|-e|-s <serialnumber>] <command>
If only one emulator is running or only one phone is connected, the ADB command is sent to the device by default. If you have more than one emulator or phone running, you need to specify which one to manipulate by using the-D,-e, or-s parameters.
4. ADB command
Cond
Resources
[1] Details of Android adb use, http://www.jizhuomi.com/android/environment/191.html
[2] Android Debug Bridge, http://developer.android.com/intl/zh-cn/tools/help/adb.html
Windows environment Android Studio V1.2.2 series 7-adb