ADB Usage Details

Source: Internet
Author: User
Tags unix domain socket

ADB, short for Android debug bridge, is a tool in the android SDK. It can be used to directly manage Android simulators or real Android devices (such as G1 mobile phones ).
Its main functions include:

* Run the shell (command line) of the device)
* Manage port ing between simulators and devices
* Upload/download files between computers and devices

* Install the local APK software on the simulator or Android device.

ADB is a client-server program, where the client is the computer you use to operate and the server is an Android device ..
First, let's talk about the installation method. You need to install the client on your computer. The client is included in the SDK. You do not need to install it on the device. You just need to open the option settings-applications-Development-USB debugging on your mobile phone.

For Mac and Linux users, after the downloaded SDK is decompressed, you can ~ Or any directory. Then modify ~ /. Bash_profile file, set the runtime environment to point to the SDK's tools directory.
Open ~ /. Bash_profile file (if this file is not available, you can add it yourself), add a line in it:
Export path =$ {path }:< your SDK directory>/tools

Then you can use the ADB command.

You can skip the installation steps and enter the full path to use the command.

For Windows XP users, install the USB driver android_usb_windows.zip first. If you only want to use ADB and do not want to download the entire SDK, download the ADB toolkit adb_win.zip and decompress it, put adb.exe and adbwinapi in it. DLL files can be stored in the Windows/system32 folder on the system disk.

 

Now let's talk about several commands commonly used by ADB.
View Devices

* ADB Devices

This command is used to view the currently connected devices. The Android devices or simulators connected to the computer are listed and displayed.
Install software

* ADB install <APK file path>

This command installs the specified APK file on the device.

Uninstall Software

* ADB uninstall <software Name>
* ADB uninstall-k <software Name>

If the-k parameter is added, the software is uninstalled but the configuration and cache files are retained.
Login device Shell

* ADB Shell
* ADB shell <command>

This command will log on to the shell of the device.
The <command> command is used to directly run the device command, which is equivalent to executing the remote command.
Send files from computer to Device

* ADB push <local path> <remote path>

Use the push command to copy files or folders on the local computer to the device (mobile phone)
Download files from your device to your computer

* ADB pull <remote path> <local path>

Run the pull command to copy files or folders on the device (mobile phone) to the local computer.
Show Help Information

* ADB help

This command displays help information

There is also an English version:

Enter the following command in DOS to complete the flash task. Some Common commands are described as follows:

ADB Devices-List the ADB devices connected to the computer (that is, mobile phones). The mobile phone P/N code is usually displayed. If not displayed, the mobile phone is not connected to the computer.
ADB install <packagename.apk>-Install the mobile phone software to your mobile phone, for example, ADB install qq2009.apk.
ADB remount-Re-enable the phone write mode (flash mode ).
ADB push <localfile> <location on your phone>-Transfer a file to your mobile phone, for example, ADB push recovery. img/sdcard/recovery. IMG. Transfer the recovery. IMG file in the local directory to the SD card of your mobile phone and get the same file name.
ADB pull <location on your phone> <localfile>-Transfer the mobile phone file to the local directory (opposite to the command on ).

ADB shell <command>
-Let the phone execute the command, <command> is the command executed by the phone. For example: ADB shell flash_image recovery/SD-card/recovery-RAv1.0G.img, execute to write the recovery-RAv1.0G.img into the recovery area.

We usually execute the following commands in the order of recovery:

ADB shell Mount-

ADB push recovery-RAv1.0G.img/system/recovery. img

ADB push recovery-RAv1.0G.img/sdcard/recovery-RAv1.0G.img

ADB shell flash_image recovery/sdcard/recovery-RAv1.0G.img reboot

Others can be used flexibly.

Detailed description of the ADB command:
Android debug bridge version 1.0.20
-D-directs command to the only connected USB device returns an error if more than one USB device is present.
-E-directs command to the only running emulator. returns an error if more than one emulator is running.
-S <serial number>-directs command to the USB device or emulator withthe given serial number
-P <product name or path>-simple product name like 'sooner ', or a relative/absolute path to a product out directory Like 'out/target/product/sooner '.
If-P is not specified, the android_product_out environment variable is used, which must be an absolute path.
Devices-list all connected devices
Device commands:
ADB push <local> <remote>-copy file/DIR to Device
ADB pull <remote> <local>-copy file/DIR from Device
ADB sync [<directory>]-copy host-> device only if changed (see 'adb help all ')
ADB shell-run remote shell interactively
ADB shell <command>-run remote shell command
Adb emu <command>-run emulator Console Command
ADB logcat [<filter-spec>]-view device log
ADB forward <local> <remote>-forward socket connections
Forward specs are one:

TCP: <port>
Localabstract: <Unix domain socket name>
Localreserved: <Unix domain socket name>
Localfilesystem: <Unix domain socket name>
Dev: <character device name>
Jdwp: <process pid> (Remote Only)

ADB jdwp-list PIDs of processes hosting a jdwp transport
ADB install [-L] [-R] <File>-push this package file to the device and install it
('-L' means forward-lock the app)
('-R' means reinstall the app, keeping its data)
ADB uninstall [-K] <package>-Remove this app package from the device
('-K' means keep the data and cache Directories)
ADB bugreport-return all information from the device that should be stored in a bug report.
ADB help-show this help message
ADB version-show version num

Dataopts:
(No option)-Don't touch the Data Partition
-W-wipe the Data Partition
-D-flash the Data Partition
Scripting:
ADB wait-for-device-block until device is online
ADB start-server-ensure that there is a server running
ADB kill-server-kill the server if it is running
ADB get-state-prints: offline | bootloader | Device
ADB get-serialno-prints: <serial-number>
ADB status-window-continuously print device status for a specified device
ADB remount-remounts the/system partition on the device re
Ad-write
ADB root-restarts ADB with root permissions
Networking:
Adb ppp <tty> [parameters]-Run PPP over USB.
Note: You shoshould not automatically start a PDP connection.
<Tty> refers to the TTY for PPP stream. eg. Dev:/dev/omap_csmi_tty1
[Parameters]-eg. defaultroute debug dump local notty usepeerdns
ADB sync notes: ADB sync [<directory>]
<Localdir> can be interpreted in several ways:
-If <directory> is not specified, both/System and/Data partitions will be updated.
-If it is "system" or "data", only the corresponding partition is updated

 

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.