Android debug bridge (Official Website Introduction)

Source: Internet
Author: User

Link: http://developer.android.com/tools/help/adb.html #

Android debug bridge (ADB) is a versatile command line tool that connects you to an android simulator or a real Android device, is a client-server-mode application, which includes the following three components:

1. A client running on your development machine, you can use shell to send an ADB command, and Other Android tools, such as the ADT plug-in and ddms, will also create an ADB Client

2. A background process runs on the server on your machine. The server manages the connection between the client and the ADB daemon running on the device.

3. A daemon that runs with background processes on the device instance

You can<sdk>/platform-tools/. Find the ADB tool.

When you start an ADB client, first check whether an ADB server process is running. If not, it starts a server process. After the server process starts, it binds the local tcp5037 port and listens to commands sent from the ADB client (all ADB clients use port 5037 to connect to the ADB server ).

The server starts to connect all the started Simulators/real device instances. It listens to the odd ports from 5555 to 5585 to load the device instance. If the server finds an ADB daemon, A connection is started on this port. Note that each device instance requires a pair of ports, one for connecting to the console, and the other for connecting to the ADB client. For example:

Emulator
1, console: 5554
Emulator 1, ADB: 5555
Emulator 2, console: 5556
Emulator 2, ADB: 5557

 
As shown above, the ADB of a simulator instance is connected to port 5555, while the console listens to port 5554.

 
Syntax:
You can use the command line or script to publish an ADB command on the machine you developed. The usage is as follows: ADB
[-D |-E |-S <serialnumber>] <command>
If only one device is connected, the ADB command is sent to this device by default. However, if multiple devices are running, you need to use the-d-e or-s option to specify a target device to execute the ADB command.
Command line:
The following list lists all available ADB commands, and lists examples of explanations and usage. (Note: Since the csdn table is too simple to edit the list on the ADB official website, I decided to write it for a while)
Query a device instance:
Before sending the ADB command, you can know which device instances are useful for connecting to the ADB server. You can use the device command to generate a list of connected devices: ADB.
In response, ADB lists the status information of all instances: 1. serial number: A string created by ADB that uniquely identifies a device instance. It is generated using the Console Port Number of the device. The serial number is in the format of <type>-<consoleport>, for example: emulator-5554. 2. status: the instance connection status may be as follows: ). offline-the instance is not connected to ADB or the instance does not respond to B ). device-the instance has been connected to the ADB server. (Note: this status does not indicate that the Android system is completely introduced and can be operated, this device may be connected to ADB and still being imported. After the import is complete, this is a common device instance operation. c) No device-no device is connected to ADB. Here is an example output after the device command is input:
ADB Devices
List of device attached
Emulator-5554 Device
Emulator-5556 Device
Emulator-5558 Device
Run the ADB command on a specific device: if multiple device instances are running, you must specify a target instance before sending the ADB command, you can add the-s option to the command line. The usage is as follows: ADB-S <serialnumber> <command> As shown above, you can use the serial code assigned by ADB to specify a target instance. You can use the devices command to obtain the serial number. The following is an example: ADB-s emulator-5556 install
Helloworld.apk (Note: if you do not specify a specific device instance before sending the command, but multiple devices are available, ADB will return an error message) if you have multiple devices available (hardware or simulator) but only one simulator, you can simply use the-E Option to send commands to the simulator. Similarly, if there are multiple device instances but only one is hardware, you can use the-D option to send commands to the hardware device. Install the application: You can use ADB to copy an application from your development computer and install it on the device instance. To do this, you need to use the install command. To use this command, you must specify the path of the APK you want to install. ADB install <path to APK> copy files from the device instance/copy files to the device instance: You can use the pull command of ADB to copy a file to the device instance, push copies a file from the device instance to the computer. Unlike the install command, only one APK file is copied to a specified location, the pull and push commands allow you to copy arbitrary files or folders to any device instance. To copy a file or folder from a device instance, use the following command: ADB pull <remote> <local> if you want to copy a file or folder to a device instance, do the following: ADB push <local> <remote> In this command, <local> and <remote> are specific file or folder locations, for example: ADB push foo.txt/sdcard/foo.txt sends the shell command: Because the shell command involves UNIX, and I don't understand it at all, so the following is not translated. After the command is completed, close the job!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.