Common Android adb commands

Source: Internet
Author: User
Tags unix domain socket

1. query several android devices connected to the adb server
> Adb devices
List of devices attached
0123456789 ABCDEF device
2. install an apk to the android device.
> Adb install-r B: test6577PinyinIME.apk
2509 KB/s (1284852 bytes in 0.499 s)
Pkg:/data/local/tmp/PinyinIME.apk
Success
-R indicates forced installation. When the system has this apk, this option is added to ensure that the new apk is installed.
3. Copy files from local device
> Adb push B: test6577PinyinIME.apk/data/app
3491 KB/s (1284852 bytes in 0.359 s)
4. Copy files from the device to the local device
> Adb pull/data/app ./
Pull: building file list...
Pull:/data/app/com.android.inputmethod.pinyin-2.apk->./com.android.inputmethod.pinyin-2.apk
Pull:/data/app/PinyinIME.apk->./PinyinIME.apk
Pull:/data/app/com.google.android.inputmethod.pinyin-1.apk->./com.google.android.inputmethod.pinyin-1.apk
3 files pulled. 0 files skipped.
4766 KB/s (10981224 bytes in 2.249 s)
This command copies all the apk files in the/data/app directory of the device to the local directory.
5. Go to shell
In this way, you can run commands in linux.
> Adb shell
Root @ android:/# logcat
6. Restart adb server
> Adb kill-server
> Adb start-server
* Daemon not running. starting it now on port 5037 *
* Daemon started successfully *
These commands are often used. remember them ~
Adb also has many usage options. You can use adb help.
> Adb help
Android Debug Bridge version 1.0.26


-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
The given serial number. Overrides ANDROID_SERIAL
Environment variable.
-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
Connect Port 5555 is used by default if no port number is specified.
Disconnect [Port 5555 is used by default if no port number is specified.
Using this ocmmand with no additional arguments
Will disconnect from all connected TCP/IP 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
(-L means list but don't copy)
(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] [-s] <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)
('-S' means install on SD card instead of internal storage)
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 shoshould be added 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 read-write
Adb reboot [bootloader | recovery]-reboots the device, optionally into the bootloader or recovery program
Adb reboot-bootloader-reboots the device into the bootloader
Adb root-restarts the adbd daemon with root permissions
Adb usb-restarts the adbd daemon listening on USB
Adb tcpip <port>-restarts the adbd daemon listening on TCP on the specified port
Networking:
Adb ppp <tty> [parameters]-Run PPP over USB.
Note: you shoshould not automatically start a PPP 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.


Environmental variables:
ADB_TRACE-Print debug information. A comma separated list of the following values
1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
ANDROID_SERIAL-The serial number to connect to.-s takes priority over this if given.
ANDROID_LOG_TAGS-When used with the logcat option, only these debug tags are printed.

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.