Adb--android's ADB tools use

Source: Internet
Author: User
Tags unix domain socket

I. Definition and function:

ADB full name Android Debug Bridge, is to play the role of the Debug bridge. is a tool in the Android SDK that allows you to manipulate the Android emulator or the real andriod device directly, by default the ADB process will run automatically when we run eclipse. Of course, we can also use some of the commands that we have on the outside to manipulate the simulator or the real device. ADB is typically located in the <sdk>/platform-tools/directory, where <sdk> is the installation directory for the Android SDK. Its main functions are:

(1) Quickly update the code in the device or phone simulator, such as app or Android system upgrade;
(2) Run the shell command on the device;
(3) Management equipment or mobile phone simulator on the predetermined port;

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

Second, configure the environment variables:

1. Open the Environment Variable Configuration window. Right-click Computer, Properties-Advanced system settings-environment variables.

2. Below you can build a separate variable, or directly after the path directly appended, mainly personal habits bar. Note that you must specify the directory as: D:\Android\Android-sdks\tools. This is my catalogue.

3. The results of the successful operation of the editor are as follows:


Third, the use of code

1.

ADB version Information 

C:\USERS\ADMINISTRATOR>ADB version
Android Debug Bridge Version 1.0.31

2.

Install and Uninstall Apps
You can install an app on Emulator/device from development computer by using the Install command.
Usage: adb install <path_of_apk>

You can uninstall the installed software by using the uninstall command.
1.usage: adb uninstall Name-of-app-package
Where Name-of-app-package is the installation package under the/data/data directory.

2. Manually Delete

ADB shell
Cd/data/app
RM app.apk

3.

. Copying Files

You can use ADB pull, the push command to copy files to a data file for an emulator/device instance, or to copy from a data file. The install command only copies an apk file to a specific location, unlike the pull and push commands, which allow users to copy arbitrary directories and files to any location on an emulator/device instance.

To copy a file or directory from a simulator or device, use the following command:

ADB pull <remote> <local>

To copy a file or directory to an emulator or device, use the following command:

ADB push <local> <remote>

In these commands, <local> and <remote> refer to the path to the destination file/directory on your own development machine (local) and emulator/Device instance (remote) .

Here's an example:

ADB push Foo.txt/sdcard/foo.txt

4.

Send files from your computer to your device
ADB Push < Local path > < remote path >
Use the push command to copy files or folders on your computer to your device (mobile)

5.

Download files from your device to your computer
ADB pull < Remote path > < local path >
Use the pull command to copy files or folders on your device (phone) to your local computer

6.

View Device
ADB devices
This command is to view the currently connected device, the Android device connected to the computer, or the emulator will list the display

7. ADB logcat use Logcat command

8.
Filtering log output

Each output of the Android log information has a label and its priority.

    • The label of the log is a brief indication of the original information of the system part. (For example, "View" is to view the system's label).
    • Priority has the following concentrations, which are arranged smoothly from low to High:
      • V-verbose (Lowest priority)
      • D-debug
      • I-info
      • W-warning
      • E-error
      • F-fatal
      • S-silent (highest priority, on which nothing is ever printed)

9.

Control log Output format

The log information includes many metadata fields including labels and precedence. You can modify the output format of the log so that a specific metadata field can be displayed. Information about -v the output log can be formatted with the option.

    • brief-display Priority/tag and PID of originating process (the default format).
    • process-display PID only.
    • tag-display the Priority/tag only.
    • thread-display Process:thread and Priority/tag only.
    • raw-display the raw log message with and no other metadata fields.
    • time-display the date, invocation time, Priority/tag, and PID of the originating process.
    • long-display all metadata fields and separate messages with a blank lines.

When started logcat , you can specify the -v output format with the option:

[ADB] logcat [-v <format>]

The following are thread the resulting log formats:

ADB logcat-v Thread

Note that you can only have -v options to specify the output format option.

10.

Start shell command

The ADB provides the shell side, through the shell side you can run various commands on the emulator or device. These commands are stored in the file system of the local emulator or device in 2 binary form:

/system/bin/...

Whether or not you fully enter the ADB remote shell of the simulator/device, you can shell command to execute the command.

When not fully entering the remote shell, use the shell command to execute a command:

adb [-d|-e|-s {<serialnumber>}] Shell <shellCommand>

When you do not use the remote shell side in the simulator/device, this uses the shell life:

adb [-d|-e|-s {<serialnumber>}] Shell

The CTRL+D exit shell remote connection can be exited either by operation or by.

Some of the following will tell you more about shell commands.

ADB command table

The following table lists all the commands supported by ADB and describes their meanings and how they are used.

Category

Command

Description

Comments

Options

-D

Manage ABD only via USB interface

Return error if not only managed with USB interface

-E

Manage adb only through simulator instances

Returns an error if it is not managed only by the emulator instance

-S <serialNumber>

Manage adb by sending commands via the simulator/device's allow command number (e.g. "Emulator-5556″")

If no number is specified, an error is given

General

Devices

View a list of all the facilities that connect the simulator/device

Find out more about querying for Emulator/device Instances

Help

View all the commands supported by ADB

Version

View ADB's version serial number

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 for a specified facility

You can use the forward jdwp:<pid> port mapping information to connect to the specified JDWP process, for example:
ADB forward tcp:8000 jdwp:472
Jdb-attach localhost:8000

Data

Install <path-to-apk>

Install Android for (can simulator/facility data file. APK specifies the full path)

Pull <remote> <local>

Copy the specified file from the emulator/facility to the computer

Push <local> <remote>

Copy the specified file from the computer to the emulator/device

Ports and Networking

Forward <local> <remote>

Remote connection Simulator/facility using the socket method with a locally specified port

The port needs to describe the following information:

  • Tcp:<portnum>
  • Local:<unix Domain Socket name>
  • Dev:<character Device name>
  • Jdwp:<pid>

PPP <tty> [Parm] ...

To run PPP via 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.

You need to be reminded that PDP connections cannot be started automatically

Scripting

Get-serialno

To view the serial number of an ADB instance

View querying for Emulator/device Instances to get more information

Get-state

View the current status of the simulator/facility

Wait-for-device

If the device is not online, it is not allowed to execute, that is, when the instance state is device

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

ADB wait-for-device Shell Getprop

It is necessary to note that these commands do not start the ADB until all the systems start up, so no other commands can be executed until all the systems start up, for example, when the install is used, the Android package needs to be fully booted, for example:

ADB wait-for-device Install <app>.apk

The above command is only connected to the emulator/device connection on which the ADB service will be executed, and an error will occur before the Android system is fully booted.

Server

Start-server

Select whether the service starts the ADB service process

Kill-server

Terminate ADB service process

Shell

Shell

Controlling emulator/Device instances with remote shell commands

See more information For more information

Shell [<shellcommand>]

Connection Simulator/Facility Execute shell command, exit remote shell end after execution

Adb--android's ADB tools use

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.