官方网站:http://adbshell.com/
Android Debug Bridge(adb)是一个命令行工具,可让您与模拟器或连接的Android设备进行通信。您可以在android sdk / platform-tools或下载ADB工具包中找到adb工具。
如何在Windows上使用ADB 命令
在<Android SDK> / platform-tools文件夹中找到adb.exe或下载ADB工具包(zip包解压后有:adb.exe,AdbWinApi.dll,AdbWinUsbApi.dll)
注意:Android SDK路径:%LOCALAPPDATA%\ Android \ sdk => C:\ Users \ <用户名> \ AppData \ Local \ Android \ sdk
打开命令提示符。(按Windows键+ R,键入“cmd”)
设置环境变量:电脑设置》高级属性》系统变量,找到“path”,选中后点击“编辑”,把adb所在目录加到里面。
配置成功后,就不用进入到adb所在目录,直接输入adb命令就OK
C:\Users\adm>cd C:\Users\adm\Desktop\adb
C:\Users\adm\Desktop\adb>adb devices
(adb devices会先启动再展示连接的设备。
如果用命令启动是adb start-server。
用命令停止进程是 adb kill-server。
注意:我的华为p20手机是不允许wifi模式下 adb connect 总是连接不上。
“仅充电”模式下允许ADB调试,不能wifi模式下ADB调试)
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
ADB COMMANDS
Android Debug Bridge version 1.0.32
-a - directs adb to listen on all interfaces for a connection
-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 <specific device> - directs command to the device or emulator with the given
serial number or qualifier. 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.
-H - Name of adb server host (default: localhost)
-P - Port of adb server (default: 5037)
devices [-l] - list all connected devices
('-l' will also list device qualifiers)
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number is specified.
disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.
Port 5555 is used by default if no port number is specified.
Using this command with no additional arguments
will disconnect from all connected TCP/IP devices.
device commands:
adb push [-p] <local> <remote>
- copy file/dir to device
('-p' to display the transfer progress)
adb pull [-p] [-a] <remote> [<local>]
- copy file/dir from device
('-p' to display the transfer progress)
('-a' means copy timestamp and mode)
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 --list - list all forward socket connections.
the format is a list of lines with the following format:
<serial> " " <local> " " <remote> "\n"
adb forward <local> <remote> - forward socket connections
forward specs are one of:
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 forward --no-rebind <local> <remote>
- same as 'adb forward <local> <remote>&