Android Development notes-ADB parameter Guide

Source: Internet
Author: User

ADB (Android debug Bridge)

Android provides a common debugging tool. With this tool, we can debug and developProgram, Adb.exe is in the directory of the android SDK (or platform-tools) You have installed.

ADB usage:

ADB [-d |-E |-S <serialnumber>] <command>

When you issue a command, the system enables the android client. The client is not related to the simulator instance, so if the dual server/device is running, you need to use the-D option to determine the target instance for the command to be controlled. For more information about using this option, you can view the terms control commands of the simulator/device instance. 
1. Install the application to the simulator:

You can use ADB to copy an application from your development computer and install it on a simulator/device instance. Run the install command. This installcommand requires you to specify the path of the .apk file you want to install:
ADB install <path_to_apk>
For more information about how to create a .apk file that can be installed on a simulator/device, see Android asset packaging tool (aapt ).
Note that if you are using Eclipse IDE and have installed the ADT plug-in, you do not need to directly use ADB (or aapt) to install the application on the simulator/device. Otherwise, the ADT plug-in handles application packaging and installation on your behalf.
To delete an application, follow these steps, for example, test:
ADB Shell
CD/data/APP
Rm test.apk

2. Enter the shell of the device or simulator: 
ADB Shell
Through the above command, you can enter the shell environment of the device or simulator. In this Linux Shell, You can execute various Linux commands. In addition, if you only want to execute one shell command, you can use the following methods:
ADB shell [command]
For example, ADB shell dmesg prints the kernel debugging information.

3. Release Port: 
You can set any port number as the request port from the host to the simulator or device. For example:
ADB forward TCP: 5555 TCP: 8000

4. Import or copy files from the simulator/device: 
You can use the adbpull and push commands to copy files to or from a data file of a simulator/device instance. The installcommand only copies a .apk file to a specific location. Unlike the command, the pull and push commands allow you to copy arbitrary directories and files to any location of a simulator/device instance.
Copy a file or directory from a simulator or device and use the following command ):
ADB pull <remote> <local>
Copy the file or directory to the simulator or device and use the following command)
ADB push <local> <remote>
In these commands, <local> and <remote> indicate the path to the target file/directory on the development machine (local) and simulator/device instance (remote) respectively.
The following is an example:
ADB push test.txt/data/DAT/test/test.txt,

5. query Simulators/device instances: 
Before releasing the ADB command, it is necessary to know what kind of simulator/device instance is connected to the ADB server. You can use devices
Command to obtain a series of associated Simulators/devices:
ADB Devices

In response, ADB develops the corresponding status information for each instance:
Serial number-a string created by ADB. This string uniquely identifies a simulator/device instance through its own control port <type>-<consoleport>.
The following is an example of a serial number:
Emulator-5554
There are three instance connection statuses:
Offline-this instance is not connected to ADB or cannot respond.
Device-this instance is connected to the ADB server. Note that this status does not indicate that the system is running and operating the Android system. Therefore, this instance is connected to ADB when the system is running. However, after the system is started, it is a normal running status of the simulator/device.
The output format of each instance is fixed as follows:
[Serialnumber] [State]
The following is an example of the devices command and output:
$ ADB Devices
List of devices attached
Emulator-5554 Device
Emulator-5556 Device
Emulator-5558 Device
If no simulator/device is running, ADB returns no device

6. view the bug report: 
ADB bugreport

7. Record wireless communication logs: 
In general, there are a lot of wireless communication logs and there is no need to record them during operation, but we can still set the record through the command:
ADB Shell
Logcat-B radio

8. Get the device ID and serial number: 
ADB get-Product
ADB get-serialno

9. Access the database sqlite3 
ADB Shell
Sqlite3

To open an existing database:

Sqlite3 <path>/dbname. DB

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.