ADB 命令解释

上一篇 / 下一篇  2009-06-17 13:23:16 / 个人分类:Android

我的栏目
  • 栏目:Linux

命令行工具ADBAndvoid Debug Bridge)是Android提供的一个通用的调试工具,借助这个工具,我们可以管理设备或手机模拟器的状态。51Testing软件测试网 y(\|2{u5^;th

 

.N3`6u+L8E0

adb help51Testing软件测试网FQF6t-bu rX

 51Testing软件测试网:vA MplJ%?-t

AndroidDebugBridgeversion 1.0.2051Testing软件测试网]j)[1ms b;I

 

'v:bn b,| e%?8w0

 -d                      - directs command to the only connected USB device

4U5t4|LXs6AY0

                           returns an error if more than one USB device is present.51Testing软件测试网'b/Ae7BA_P#I}

 -e                      - directs command to the only running emulator.

.u`(M3W}lh*E0

                           returns an error if more than one emulator is running.51Testing软件测试网Uq9s6pH]oB3j

 -s <serial number>      - directs command to the USB device or emulator with

nU/Z!M:qj,BV s0

                           the given serial number51Testing软件测试网[1e2?-?fGV

 -p <product name or path>  - simple product name like 'sooner', or

u7ox*\ekdo6f0

                              a relative/absolute path to a product

"~PLb,@`kD@0

                                out directory like 'out/target/product/sooner'.51Testing软件测试网@vZ}^*yS Z

                              If -p is not specified, the ANDROID_PRODUCT_OUT51Testing软件测试网Lj[O:f_Q

                                environment variable is used, which must51Testing软件测试网amw:C hPdW

                              be an absolute path.

o0oP[vC0

 devices                 - list all connected devices

xmk9G k0?0

 51Testing软件测试网*| kKgE}b

device commands:51Testing软件测试网0o.zO$nn t l

 adb push <local> <remote>   - copy file/dir to device

8n@'zmsKgg1o1F0

 adb pull <remote> <local>   - copy file/dir from device

@Rw|"jK2@0

 adb sync [ <directory> ]    - copy host->device only if changed51Testing软件测试网(c.JQOQU J,E

                                (see 'adb help all')

~|2c5_D#h]0

 adb shell                   - run remote shell interactively

+d3t'xQ'[,i6g:u0gWg.v0

 adb shell <command>         - run remote shell command51Testing软件测试网:ma'`W X j"t

 adb emu <command>           - run emulator console command51Testing软件测试网b'w W![/D{

 adb logcat [ <filter-spec> ] - View device log

$S;lc EY5_\:c0

 adb forward <local> <remote> - forward socket connections51Testing软件测试网)B#Q/o^;};`

                                forward specs are one of:51Testing软件测试网Yk&JjW3n

                                  tcp:<port>51Testing软件测试网 b t4L_'@#s

                                  localabstract:<unix domain socket name>51Testing软件测试网4ma*wdw8\8b Ia;x

                                  localreserved:<unix domain socket name>51Testing软件测试网L.@oL8\ T`;W [

                                  localfilesystem:<unix domain socket name>

v"Y!w'|w'?0c~%H0

                                  dev:<character device name>51Testing软件测试网i];Y.y X#NsJ7qo

                                  jdwp:<process pid> (remote only)

M3qW\)Z N0

 adb jdwp                    - list PIDs of processes hosting a JDWP transport

w0d|:[o KETK&l0

 adb install [-l] [-r] <file> - push this package file to the device and install it51Testing软件测试网Nj0V~oG6T8Z.u

                                ('-l' means forward-lock the app)51Testing软件测试网:a8z~+K$N rI%ax?G H.t

                                ('-r' means reinstall the app, keeping its data)

4V oT/xUi0

 adb uninstall [-k] <package> - remove this app package from the device51Testing软件测试网[\R l_h-Fg#O

                                ('-k' means keep the data and cache directories)51Testing软件测试网2oLSfY6i+mf

 adb bugreport               - return all information from the device

W(^]%D9PqIz0

                                that should be included in a bug report.51Testing软件测试网$v K m!w+@,y,Q7C](H

 51Testing软件测试网3o1L'Zk!w&aOHA dWk

 adb help                    - show this help message

&S7ZK'n6V/d^*g*S9S0

 adb version                 - show version num51Testing软件测试网B~ZY4GFMB$R

 51Testing软件测试网p7f#z8e7e

DATAOPTS:

,A ]RN(qp0

 (no option)                  - don't touch the data partition51Testing软件测试网a]!@*{ic

 -w                          - wipe the data partition51Testing软件测试网3A{x+j*R:{ H{

 -d                          - flash the data partition

8O(ema[OCQ0

 

3{V'By!v{0

scripting:

7g6bl"Ao2A+iwRK F0

 adb wait-for-device         - block until device is online51Testing软件测试网9]3n'z+g&s9@+k YR

 adb start-server            - ensure that there is a server running

by|+A5wS|n q0

 adb kill-server             - kill the server if it is running51Testing软件测试网%Q1?VC} hFv

 adb get-state               - prints: offline | bootloader | device

`M9\9F-c Ia0

 adb get-product             - prints: <product-id>51Testing软件测试网UwTkN,S

 adb get-serialno            - prints: <serial-number>

8N6GW@ Y!B Fi)`A%K0

 adb status-window           - continuously print device status for a specified device

zv+?U*a&avcKY0

 adb remount                 - remounts the /system partition on the device read-write51Testing软件测试网_S s*]9B

 

$AAnI y1DW0

networking:

_qh,oved~0

 adb ppp <tty> [parameters]  - Run PPP over USB.51Testing软件测试网JkP1Cg U(| {'Ut

 Note: you should not automatically start a PDP connection.

q AR a)yw0

 <tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1

n N&[bd%k0

 [parameters] - Eg. defaultroute debug dump local notty usepeerdns

S`0w!s5X(Wl4R0

 51Testing软件测试网?5G8Z[s7is3C

adb sync notes: adb sync [ <directory> ]

x/Gj"C2E&kN0

 <localdir> can be interpreted in several ways:51Testing软件测试网[:qd4^*q o a+V

 

T\5SNp!\9q @K0

 - If <directory> is not specified, both /system and /data partitions will be updated.

_z)q8O"pA0

 51Testing软件测试网(ohGE)d

 - If it is "system" or "data", only the corresponding partition51Testing软件测试网b+D J6G%H$W a

   is updated.51Testing软件测试网$x|Lc1[j

 

'rJF5Q{ `8h"Fp0

 

A1m|;H m"x)`M0

ADB还可以进行以下的操作:

+} H5l0YS t#ME)B0

1、快速更新设备或手机模拟器中的代码,如应用或Android系统升级;51Testing软件测试网o3c4R+e"ojK

2、在设备上运行shell命令;

[1`1aEu h/N0

3、管理设备或手机模拟器上的预定端口;51Testing软件测试网,T(D/y.Y}E f&R

4、在设备或手机模拟器上复制或粘贴文件;51Testing软件测试网&w.p? K X

5、安装.apk文件到仿真器上。

O5wN K#t,H J0

 

'u:UV`^ q0

以下为一些常用的操作:

!_(n0}9D!|"]5{P)o-O0

1、安装应用到模拟器:51Testing软件测试网)S&J`K PA1TL*?4W1R

adb install51Testing软件测试网W;e.`h0}@)P{ hG

比较郁闷的是,Android并没有提供一个卸载应用的命令,只能自己手动删除:51Testing软件测试网|e\ b,yJV

adb shell

&jXd)Zi/D0

cd /data/app51Testing软件测试网U/uf-e j d*hE1Ky V

rm app.apk

RJ+~;?$N0

 

-qA*A-_zL6{7v0

2、进入设备或模拟器的shell

'{3WM6]{|0

adb shell

Rs(u:j2[4Zy!@B.W0

通过上面的命令,就可以进入设备或模拟器的shell环境中,在这个Linux Shell中,你可以执行各种Linux的命令,另外如果只想执行一条shell命令,可以采用以下的方式:

,_E6D.[9kS&C;j0

adb shell [command]

!n%Q`.Q\HU0

如:adb shell dmesg会打印出内核的调试信息。51Testing软件测试网 I8FZ#A1_Pi

 51Testing软件测试网2rUaV#XOM~{

3、发布端口:

1HzG-ym Y0

你可以设置任意的端口号,做为主机向模拟器或设备的请求端口。如:51Testing软件测试网,H1n5v w `A|5~L6~0L^

adb forward tcp:5555 tcp:8000

)Xq$l;m e0

 51Testing软件测试网9O9Ps7K)`F&W#aE

4、复制文件:

8n0tLbL |1nK0

你可向一个设备或从一个设备中复制文件,

{W9CV@9Ky0

复制一个文件或目录到设备或模拟器上:51Testing软件测试网-t8AiM)a%c#Z

adb push

.]SE&|'x$t2ly0

如:adb push test.txt /tmp/test.txt

Rn|[0P6w#p{0

从设备或模拟器上复制一个文件或目录:51Testing软件测试网,h.~#m4s8xFW$@S%Tv

adb pull51Testing软件测试网$Mh)mq3Zb Alc

如:adb pull /addroid/lib/libwebcore.so .

1|Wq1[2m&W]+vq0

 

s t)zO#{D C9C0

5、搜索模拟器/设备的实例:

+{Ip!m_$y0g7h^/| E0

取得当前运行的模拟器/设备的实例的列表及每个实例的状态:51Testing软件测试网I:^ vAuOf

adb devices

8A qR4g:^J7Q I0

 

YX N2X @s0

6、查看bug报告:51Testing软件测试网 ^6fyx"EjC

adb bugreport51Testing软件测试网;``+H)PzZ,m"a;F

 51Testing软件测试网1XWo!L9X8qF0m4v^@!}

7、记录无线通讯日志

;Z&``r0i Vzc0

一般来说,无线通讯的日志非常多,在运行时没必要去记录,但我们还是可以通过命令,设置记录:

Pv"P3NH;mI0

adb shell51Testing软件测试网Bx#YB"L z

logcat -b radio

vB#\5t+r'P:u2Z0

 51Testing软件测试网#\ vVz3qo@3B \9}$D

8、获取设备的ID和序列号:

j:l j~h0

adb get-product

q,rGJ{y2Ni0

adb get-serialno

v.V$x | vI x%_0

 

l|-g5E`/P D*~0

9、访问数据库SQLite351Testing软件测试网"x$KQ+Y \%h%eK

adb shell51Testing软件测试网J9yH8s+cFoE

sqlite351Testing软件测试网^'i \8]e#w6`&k6vV*i


TAG: Android android Linux linux

 

评分:0

我来说两句

Open Toolbar