配置环境变量
右键我的电脑 -> 属性 -> 高级 -> 环境变量 -> Path
在Path中添加Android SDK安装路径中 adb.exe 的路径,例如【\sdk\ platform-tools】 ,注意用【;】分号隔开。
另外,最好也将【\sdk\ platforms】 目录添加进去。
常用ADB命令
查看设备 adb devices
安装APP adb install apk文件路径
卸载软件 adb uninstall 软件包名
进入shell adb shell
回到根目录 cd /
回到上一级目录 cd ..
导入文件 adb push <本地路径> <手机路径>
导出文件 adb pull <手机路径> <本地路径>
获取权限 adb root
关闭adb adb kill-server
开启adb adb start-server
查看log adb logcat [-s 标签名]
选择指定的设备 adb –s <模拟器名称> (后面要选择执行的命令)
获取root权限 su[用户名,如root]
查看文件结构 ls
查看占用端口的进程 netstat -ano
全部命令
Android Debug Bridge version 1.0.32Revision 09a0d98bebce-android -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- directs command to the device or emulator with the given serial number or qualifier. Overrides ANDROID_SERIAL environment variable. -p - 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 [: ] - connect to a device via TCP/IP Port 5555 is used by default if no port number is specified. disconnect [ [: ]] - 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] - copy file/dir to device ('-p' to display the transfer progress) adb pull [-p] [-a] [ ] - copy file/dir from device ('-p' to display the transfer progress) ('-a' means copy timestamp and mode) adb sync [ ] - copy host->device only if changed (-l means list but don't copy) adb shell - run remote shell interactively adb shell - run remote shell command adb emu - run emulator console command adb logcat [ ] - View device log adb forward --list - list all forward socket connections. the format is a list of lines with the following format: " " " " "\n" adb forward - forward socket connections forward specs are one of: tcp: localabstract: localreserved: localfilesystem: dev: jdwp: (remote only) adb forward --no-rebind - same as 'adb forward ' but fails if is already forwarded adb forward --remove - remove a specific forward socket connection adb forward --remove-all - remove all forward socket connections adb reverse --list - list all reverse socket connections from device adb reverse - reverse socket connections reverse specs are one of: tcp: localabstract: localreserved: localfilesystem: adb reverse --norebind - same as 'adb reverse ' but fails if is already reversed. adb reverse --remove - remove a specific reversed socket connection adb reverse --remove-all - remove all reversed socket connections from device adb jdwp - list PIDs of processes hosting a JDWP transport adb install [-lrtsdg] - push this package file to the device and install it (-l: forward lock application) (-r: replace existing application) (-t: allow test packages) (-s: install application on sdcard) (-d: allow version code downgrade) (-g: grant all runtime permissions) adb install-multiple [-lrtsdpg] - push this package file to the device and install it (-l: forward lock application) (-r: replace existing application) (-t: allow test packages) (-s: install application on sdcard) (-d: allow version code downgrade) (-p: partial application install) (-g: grant all runtime permissions) adb uninstall [-k] - 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 included in a bug report. adb backup [-f ] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [ ] - write an archive of the device's data to . If no -f option is supplied then the data is written to "backup.ab" in the current directory. (-apk|-noapk enable/disable backup of the .apks themselves in the archive; the default is noapk.) (-obb|-noobb enable/disable backup of any installed apk expansion (aka .obb) files associated with each application; the default is noobb.) (-shared|-noshared enable/disable backup of the device's shared storage / SD card contents; the default is noshared.) (-all means to back up all installed applications) (-system|-nosystem toggles whether -all automatically includes system applications; the default is to include system apps) ( is the list of applications to be backed up. If the -all or -shared flags are passed, then the package list is optional. Applications explicitly given on the command line will be included even if -nosystem would ordinarily cause them to be omitted.) adb restore - restore device contents from the backup archive adb disable-verity - disable dm-verity checking on USERDEBUG builds adb enable-verity - re-enable dm-verity checking on USERDEBUG builds adb keygen - generate adb public/private key. The private key is stored in , and the public key is stored in .pub. Any existing files are overwritten. adb help - show this help message adb version - show version numscripting: 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: adb get-devpath - prints: adb remount - remounts the /system, /vendor (if present) and /oem (if present) partitions on the device read-write adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program. adb reboot sideload - reboots the device into the sideload mode in recovery program (adb root required). adb reboot sideload-auto-reboot - reboots into the sideload mode, then reboots automatically after the sideload regardless of the result. adb sideload - sideloads the given package adb root - restarts the adbd daemon with root permissions adb unroot - restarts the adbd daemon without root permissions adb usb - restarts the adbd daemon listening on USB adb tcpip - restarts the adbd daemon listening on TCP on the specified portnetworking: adb ppp [parameters] - Run PPP over USB. Note: you should not automatically start a PPP connection. refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1 [parameters] - Eg. defaultroute debug dump local notty usepeerdnsadb sync notes: adb sync [ ] can be interpreted in several ways: - If is not specified, /system, /vendor (if present), /oem (if present) and /data partitions will be updated. - If it is "system", "vendor", "oem" or "data", only the corresponding partition is updated.environment 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.
x
1
Android Debug Bridge version 1.0.32
2
Revision 09a0d98bebce-android
3
4
-a - directs adb to listen on all interfaces for a connection
5
-d - directs command to the only connected USB device
6
returns an error if more than one USB device is present.
7
-e - directs command to the only running emulator.
8
returns an error if more than one emulator is running.
9
-s- directs command to the device or emulator with the given
10
serial number or qualifier. Overrides ANDROID_SERIAL
11
environment variable.
12
-p- simple product name like 'sooner', or
13
a relative/absolute path to a product
14
out directory like 'out/target/product/sooner'.
15
If -p is not specified, the ANDROID_PRODUCT_OUT
16
environment variable is used, which must
17
be an absolute path.
18
-H - Name of adb server host (default: localhost)
19
-P - Port of adb server (default: 5037)
20
devices [-l] - list all connected devices
21
('-l' will also list device qualifiers)
22
connect[: ] - connect to a device via TCP/IP
23
Port 5555 is used by default if no port number is specified.
24
disconnect [[: ]] - disconnect from a TCP/IP device.
25
Port 5555 is used by default if no port number is specified.
26
Using this command with no additional arguments
27
will disconnect from all connected TCP/IP devices.
28
29
device commands:
30
adb push [-p]
31
- copy file/dir to device
32
('-p' to display the transfer progress)
33
adb pull [-p] [-a][ ]
34
- copy file/dir from device
35
('-p' to display the transfer progress)
36
('-a' means copy timestamp and mode)
37
adb sync [] - copy host->device only if changed
38
(-l means list but don't copy)
39
adb shell - run remote shell interactively
40
adb shell- run remote shell command
41
adb emu- run emulator console command
42
adb logcat [] - View device log
43
adb forward --list - list all forward socket connections.
44
the format is a list of lines with the following format:
45
" " " " "\n"
46
adb forward- forward socket connections
47
forward specs are one of:
48
tcp:
49
localabstract:
50
localreserved:
51
localfilesystem:
52
dev:
53
jdwp:(remote only)
54
adb forward --no-rebind
55
- same as 'adb forward' but fails
56
ifis already forwarded
57
adb forward --remove- remove a specific forward socket connection
58
adb forward --remove-all - remove all forward socket connections
59
adb reverse --list - list all reverse socket connections from device
60
adb reverse- reverse socket connections
61
reverse specs are one of:
62
tcp:
63
localabstract:
64
localreserved:
65
localfilesystem:
66
adb reverse --norebind
67
- same as 'adb reverse' but fails
68
ifis already reversed.
69
adb reverse --remove
70
- remove a specific reversed socket connection
71
adb reverse --remove-all - remove all reversed socket connections from device
72
adb jdwp - list PIDs of processes hosting a JDWP transport
73
adb install [-lrtsdg]
74
- push this package file to the device and install it
75
(-l: forward lock application)
76
(-r: replace existing application)
77
(-t: allow test packages)
78
(-s: install application on sdcard)
79
(-d: allow version code downgrade)
80
(-g: grant all runtime permissions)
81
adb install-multiple [-lrtsdpg]
82
- push this package file to the device and install it
83
(-l: forward lock application)
84
(-r: replace existing application)
85
(-t: allow test packages)
86
(-s: install application on sdcard)
87
(-d: allow version code downgrade)
88
(-p: partial application install)
89
(-g: grant all runtime permissions)
90
adb uninstall [-k]- remove this app package from the device
91
('-k' means keep the data and cache directories)
92
adb bugreport - return all information from the device
93
that should be included in a bug report.
94
95
adb backup [-f] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [ ]
96
- write an archive of the device's data to.
97
If no -f option is supplied then the data is written
98
to "backup.ab" in the current directory.
99
(-apk|-noapk enable/disable backup of the .apks themselves
100
in the archive; the default is noapk.)
101
(-obb|-noobb enable/disable backup of any installed apk expansion
102
(aka .obb) files associated with each application; the default
103
is noobb.)
104
(-shared|-noshared enable/disable backup of the device's
105
shared storage / SD card contents; the default is noshared.)
106
(-all means to back up all installed applications)
107
(-system|-nosystem toggles whether -all automatically includes
108
system applications; the default is to include system apps)
109
(is the list of applications to be backed up. If
110
the -all or -shared flags are passed, then the package
111
list is optional. Applications explicitly given on the
112
command line will be included even if -nosystem would
113
ordinarily cause them to be omitted.)
114
115
adb restore- restore device contents from the backup archive
116
117
adb disable-verity - disable dm-verity checking on USERDEBUG builds
118
adb enable-verity - re-enable dm-verity checking on USERDEBUG builds
119
adb keygen- generate adb public/private key. The private key is stored in ,
120
and the public key is stored in.pub. Any existing files
121
are overwritten.
122
adb help - show this help message
123
adb version - show version num
124
125
scripting:
126
adb wait-for-device - block until device is online
127
adb start-server - ensure that there is a server running
128
adb kill-server - kill the server if it is running
129
adb get-state - prints: offline | bootloader | device
130
adb get-serialno - prints:
131
adb get-devpath - prints:
132
adb remount - remounts the /system, /vendor (if present) and /oem (if present) partitions on the device read-write
133
adb reboot [bootloader|recovery]
134
- reboots the device, optionally into the bootloader or recovery program.
135
adb reboot sideload - reboots the device into the sideload mode in recovery program (adb root required).
136
adb reboot sideload-auto-reboot
137
- reboots into the sideload mode, then reboots automatically after the sideload regardless of the result.
138
adb sideload- sideloads the given package
139
adb root - restarts the adbd daemon with root permissions
140
adb unroot - restarts the adbd daemon without root permissions
141
adb usb - restarts the adbd daemon listening on USB
142
adb tcpip- restarts the adbd daemon listening on TCP on the specified port
143
144
networking:
145
adb ppp[parameters] - Run PPP over USB.
146
Note: you should not automatically start a PPP connection.
147
refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
148
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
149
150
adb sync notes: adb sync []
151
can be interpreted in several ways:
152
153
- Ifis not specified, /system, /vendor (if present), /oem (if present) and /data partitions will be updated.
154
155
- If it is "system", "vendor", "oem" or "data", only the corresponding partition
156
is updated.
157
158
environment variables:
159
ADB_TRACE - Print debug information. A comma separated list of the following values
160
1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
161
ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given.
162
ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed.
2018-1-1