Android ADB Tool

Source: Internet
Author: User
Tags unix domain socket

The tools folder of the SDK contains the android simulator operation's Important Command ADB. ADB is called Android debug Bridge, which serves as the debugging bridge. With this tool, you can manage the status of a device or mobile phone simulator and perform the following operations:

(1) quickly update devices or mobile phone SimulatorsCodeSuch as application or Android system upgrade;
(2) Run shell commands on the device;
(3) Manage the ports on devices or mobile phone simulators;

(4) copy or paste the file on the device or mobile phone simulator.

 

ADB works in a special way by listening to socket TCP 5554 and other ports to allow the IDE to communicate with qemu. By default, ADB will use the network port related to daemon, so when we run eclipse, the ADB process will automatically run and debug Android through ddms in eclipse.ProgramYou can also call it manually. The following are some common operations for your reference.

 

1.Version Information

D: \ unsetup \ android-sdk-windows-1.0_r1 \ tools> ADB version

Android debug bridge version 1.0.20

2.Install the application to the simulator 
ADB install [-L] [-R] <File>.

File is the path of the APK file to be installed.

 

3.Uninstall installed applications

(1) Method 1:

ADB uninstall [-K] <package>.

Package indicates the name of the package of the application to be detached, and K indicates whether the application configuration information and cache data are retained.

 

(2) manually delete.
ADB Shell
CD/data/APP
Rm app.apk

4.Enter the device or simulator'sSHell
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. If you only want to execute one shell command, you can use the following methods:
ADB shell [command]
For example:

D: \ unsetup \ android-sdk-windows-1.0_r1 \ tools> ADB shell DF

/Dev: 49564 k total, 0 K used, 49564 K available (Block Size 4096)

/Sqlite_stmt_journals: 4096 k total, 0 K used, 4096 K available (Block Size 4096)

/System: 69120 k total, 65508 K used, 3612 K available (Block Size 4096)

/Data: 76544 k total, 63684 K used, 12860 K available (Block Size 4096)

/Cache: 69120 k total, 1244 K used, 67876 K available (Block Size 4096)

 

5.Forwarding Port

You can use the Forward Command to forward any port-a specific host port of a simulator/device instance forwards requests to another port. The following demonstrates how to establish forwarding from host port 7100 to simulator/device port 8100.

ADB forward TCP: 7100 TCP: 8100

Similarly, you can use ADB to create an abstract Unix domain interface. The process is as follows:

ADB forward TCP: 7100 local: logd

6.Copy a file

You can use the ADB pull and push commands to copy files to or from a data file of a simulator/device instance. The Install command only copies an APK file to a specific location, the pull and push commands allow users 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 run 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 foo.txt/sdcard/foo.txt

7.Search Simulator/Device instance
Obtains the list of running Simulators/devices and the status of each instance, for example:

D: \ unsetup \ android-sdk-windows-1.0_r1 \ tools> ADB Devices

List of devices attached

Ht843gz03305 Device

8.ViewBugReport 

D: \ unsetup \ android-sdk-windows-1.0_r1 \ tools> ADB bugreport

========================================================== ======================

= Dumpstate

========================================================== ======================

------ System Log ------

04-12 16:59:46. 521 D/showtrack (23968): myoverlay: darw .. mdefcaption = I'm here.

04-12 16:59:46. 531 D/showtrack (23968): myoverlay: darw .. mdefcaption = I'm here.

04-12 16:59:46. 531 D/showtrack (23968): myoverlay: darw .. mdefcaption = I'm here.

04-12 16:59:46. 541 D/showtrack (23968): myoverlay: darw .. mdefcaption = I'm here.

04-12 16:59:47. 391 I/activitymanager (55): starting activity: intent {comp = {com. iceskysl. itracks/COM. iceskysl. itracks. itracks }}

04-12 16:59:47. 641 D/itracks (23968): renderlistview.

04-12 16:59:47. 671 D/showtrack (23968): myoverlay: darw .. mdefcaption = I'm here.

04-12 16:59:47. 681 D/showtrack (23968): myoverlay: darw .. mdefcaption = I'm here.

9.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:

D: \ unsetup \ android-sdk-windows-1.0_r1 \ tools> ADB Shell

# Logcat-B radio

Logcat-B radio

D/htc_ril (30): (t = 1239390296) <0

D/htc_ril (30): (t = 1239390296)> at @ htcpdpfd = 0

D/htc_ril (30): (t = 1239390296) <0

D/htc_ril (30): (t = 1239390296)> at + CSQ

D/htc_ril (30): (t = 1239390296) <+ CSQ:

D/htc_ril (30): 0

D/htc_ril (30): (t = 1239390296)> at + CREG?

D/htc_ril (30): (t = 1239390296) <+ CREG:

D/htc_ril (30): 0

10.ObtainIDAnd serial number
ADB get-Product

D: \ unsetup \ android-sdk-windows-1.0_r1 \ tools> ADB get-serialno

Ht843gz03305

 

 

11. remote connectionShell runAqlite3 connecting to the database

Through the remote shell end of ADB, you can use the soft aqlite 3 command program of Android to manage the database. The SQLite 3 tool contains many commands, such as. Dump, which displays the table content. schema can display the SQL create result set of an existing tablespace. Sqlite3 also allows remote execution of SQL commands.

 

Use SQLite 3 to log on to the remote shell of the simulator according to the previous method, and then start the tool to use the SQLite 3 command. After SQLite 3 is started, you can specify the full path of the database you want to view. The simulator/device instance stores the sqlite3 database/data/<package_name>/databases/in the folder /.

 

Example:

$ ADB Shell

# Sqlite3/data/COM. example. Google. RSS. rssexample/databases/rssitems. DB

SQLite version 3.3.12

Enter ". Help" for instructions

... Enter commands, then quit...

 

SQLite>. Exit

When starting SQLite 3, you can use the shell terminal to send the SQLite 3 command. Use the exit or <Ctrl + D> combination key to exit the ADB remote shell.

 

 

 

12. ADBCommand list

The following table lists all commands supported by ADB and describes their meanings and usage.

Category

Command

Description

Comments

Options

-D

Manage Abd only through USB Interface

An error is returned if it is not managed by a USB interface.

-E

Manage ADB only through the simulator instance

An error is returned if it is not just managed by the simulator instance.

-S <serialnumber>

Use the allowed command numbers of simulators/devices to send commands to manage ADB (for example, "emulator-5556 ″)

If no number is specified, an error is returned.

General

Devices

View the list of all devices connected to simulators/devices

View querying for emulator/device instances for more information

Help

View All commands supported by ADB

 

Version

View the version serial number of ADB

 

Debug

Logcat [<option>] [<filter-specs>]

Output log data to the screen

 

Bugreport

View bug reports, such as dumpsys, dumpstate, and logcat Information

 

Jdwp

View available jdwp information of a specified facility

You can use forward jdwp: <pid> port ing information to connect to the specified jdwp process. For example:
ADB forward TCP: 8000 jdwp: 472
Jdb-Attach local host: 8000

Data

Install <path-to-APK>

Install android as (you can specify the complete path for the simulator/idea data file .apk)

 

Pull <remote> <local>

Copy the specified file from the simulator/facility to the computer.

 

Push <local> <remote>

Copy the specified file from the computer to the simulator/device.

 

Ports and networking

Forward <local> <remote>

Remotely connect to the simulator/facility through the socket method using the locally specified port

The following information is required:

  • TCP: <portnum>
  • Local: <Unix domain socket name>
  • Dev: <character device name>
  • Jdwp: <pid>

PPP <tty> [parm]…

Run PPP through USB:

  • <Tty>-the TTY for PPP stream. For exampledev:/dev/omap_csmi_ttyl.
  • [Parm]… & Mdash zero or more PPP/pppd options, such as defaultroute, local, notty, etc.

The PDP connection cannot be started automatically.

 

Scripting

Get-serialno

View the serial number of an ADB instance

View querying for emulator/device instances for more information

Get-state

View the current status of the simulator/facility

Wait-for-Device

If the device is offline, it will not be executed, that is, when the instance status is Device

The command can be reproduced in the ADB command in advance. The command in the command can not execute other commands before the simulator/device is connected. The example is as follows:

ADB wait-for-device shell getprop

Note that these commands do not start ADB before all systems start up, so other commands cannot be executed before all systems start up, for example, android packages are required when install is used. These packages must be fully started by the system, for example:

ADB wait-for-device install <app>. APK

The preceding command is executed only when the simulator/device is connected to the ADB service, and an error occurs before the Android system is fully started.

Server

Start-Server

Select whether the service starts the ADB service process

 

Kill-Server

Terminate the ADB service process

 

Shell

Shell

Use remote shell commands to Control Simulators/device instances

View more information for more information

Shell [<shellcommand>]

Connect to the simulator/facility and run the shell command. After the command is executed, exit the remote shell terminal l

 

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.