ADB 命令解释

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

我的栏目
  • 栏目:Linux

命令行工具ADBAndvoid Debug Bridge)是Android提供的一个通用的调试工具,借助这个工具,我们可以管理设备或手机模拟器的状态。

]I-V0[5u Z*B6V0

 51Testing软件测试网[(E*VF"S.QG

adb help51Testing软件测试网:pv9@#e9W

 

z7Y@(r1FSAE5ehA0

AndroidDebugBridgeversion 1.0.2051Testing软件测试网 V0B {;y3rR {+F!Q6`8_

 

.i"h/P'r,Z(q},j0

 -d                      - directs command to the only connected USB device51Testing软件测试网(O[LN6u

                           returns an error if more than one USB device is present.51Testing软件测试网.} [LX+l A

 -e                      - directs command to the only running emulator.51Testing软件测试网 N9vYu)ycQM2c^

                           returns an error if more than one emulator is running.

;`6XC[ gy7}v$~R0

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

,z*]LyHMKPk0

                           the given serial number51Testing软件测试网a|R {-H2u(yB

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

pooh L W r0

                              a relative/absolute path to a product51Testing软件测试网uB&G%O;x6F#N UQ z

                                out directory like 'out/target/product/sooner'.

8W/J[] Z0

                              If -p is not specified, the ANDROID_PRODUCT_OUT51Testing软件测试网*r d1{,E9DO#c?2a8F

                                environment variable is used, which must51Testing软件测试网5]&fz%D| d

                              be an absolute path.51Testing软件测试网WW U D Z

 devices                 - list all connected devices

p vp8n7Q^)D4LX0

 51Testing软件测试网G2oGbu+R

device commands:51Testing软件测试网L {[#\.z

 adb push <local> <remote>   - copy file/dir to device51Testing软件测试网*E:c6p@2Ia%J

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

7U*V o4GCt0

 adb sync [ <directory> ]    - copy host->device only if changed51Testing软件测试网o8h}7mF(}n

                                (see 'adb help all')51Testing软件测试网iT8uAC2M:{

 adb shell                   - run remote shell interactively

J {3M3fVos0

 adb shell <command>         - run remote shell command51Testing软件测试网Yo's#E.Bj|

 adb emu <command>           - run emulator console command

YQu%k N0

 adb logcat [ <filter-spec> ] - View device log51Testing软件测试网Hwlc6p.S s

 adb forward <local> <remote> - forward socket connections51Testing软件测试网 H,lN+kFE vn"iI

                                forward specs are one of:51Testing软件测试网,KOlp)gUGZp8z

                                  tcp:<port>

2wG tg&f W0

                                  localabstract:<unix domain socket name>

oH%@zS8z8MH0

                                  localreserved:<unix domain socket name>51Testing软件测试网#Mm)w9ET{"{D s

                                  localfilesystem:<unix domain socket name>

IsTO~c0

                                  dev:<character device name>

;h%YN)@.df6~"{*[$p0

                                  jdwp:<process pid> (remote only)51Testing软件测试网 WKK9?#I!Vf0K

 adb jdwp                    - list PIDs of processes hosting a JDWP transport51Testing软件测试网x`d2w5M.lZ?b

 adb install [-l] [-r] <file> - push this package file to the device and install it51Testing软件测试网] dPY'myJG

                                ('-l' means forward-lock the app)

'b K0t;k$Q%d0

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

P&G9ix)xH1Q?0

 adb uninstall [-k] <package> - remove this app package from the device

!i;x!K~n9{0

                                ('-k' means keep the data and cache directories)51Testing软件测试网h_8h?t5t

 adb bugreport               - return all information from the device

)e U6j'N/?-Et0

                                that should be included in a bug report.

9Ekg7uNi0

 

D8Jk6}7SY0

 adb help                    - show this help message

a+J*Q7He&q0

 adb version                 - show version num51Testing软件测试网!w0|E_/d

 51Testing软件测试网 N6L Q"KM:K3l T

DATAOPTS:51Testing软件测试网gruhFr

 (no option)                  - don't touch the data partition

Ib;Xn1gK(a3O+K0]`0

 -w                          - wipe the data partition

l.Xt#D@"F'Qq0

 -d                          - flash the data partition

r"mHe/_&f0

 51Testing软件测试网 p/a3]&z$e`L

scripting:51Testing软件测试网xp9H9d6Z"z'|

 adb wait-for-device         - block until device is online

;i/_1vbA%czt`0

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

^{Z"S+u0

 adb kill-server             - kill the server if it is running

&f*o0R7{d4Y)u0

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

\ku[#l!])u)u*P0

 adb get-product             - prints: <product-id>

vIgSl0s)K:^?0

 adb get-serialno            - prints: <serial-number>51Testing软件测试网+q7A-[PKQ"\

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

9Tl H L+iA0

 adb remount                 - remounts the /system partition on the device read-write

E-z Otn'f2D @q0

 

8E-y"I/q-N!yy:h0

networking:

(s[8\RB0s I0

 adb ppp <tty> [parameters]  - Run PPP over USB.

e5q(x$c|0I c*O i,D0

 Note: you should not automatically start a PDP connection.51Testing软件测试网Y-W,U/Ty `

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

4c ib,YkO)W0D ud0

 [parameters] - Eg. defaultroute debug dump local notty usepeerdns51Testing软件测试网.ih o2k ~o@ |

 

y{tg(e*DQ m0

adb sync notes: adb sync [ <directory> ]

3`5]|3OJV0R+Q;gr J0

 <localdir> can be interpreted in several ways:51Testing软件测试网EyI+Y"D0h&yKU$EN;I

 

+C,Z)Ar,l,{B0

 - If <directory> is not specified, both /system and /data partitions will be updated.51Testing软件测试网ju2t,q6uDeM

 

1t,`5Ze:y#\|5yu0

 - If it is "system" or "data", only the corresponding partition51Testing软件测试网b%hM_?7L+{q

   is updated.

e8jaEp0

 

[X+A"V sn"~R"b0

 51Testing软件测试网!o j0B7CvSs

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

3H,{v8Bt9B0

1、快速更新设备或手机模拟器中的代码,如应用或Android系统升级;51Testing软件测试网j|Z}[ mN-\

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

4GF6u.`6M+Q0

3、管理设备或手机模拟器上的预定端口;51Testing软件测试网~3lV G9jS~d

4、在设备或手机模拟器上复制或粘贴文件;

"j%bk fg1`0

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

~:I%G L2H"_#gM0

 

mNCC,[y,r_(L U&J0

以下为一些常用的操作:

*iO:n Sq)xNg0

1、安装应用到模拟器:

cqS$t v V ~0

adb install51Testing软件测试网Y@ y4X D YT}yJ

比较郁闷的是,Android并没有提供一个卸载应用的命令,只能自己手动删除:51Testing软件测试网 ]N'sslT,r4x

adb shell

qsN3q nxr%n0

cd /data/app

'jUw+\-UT p3ju0

rm app.apk

^h(fP-S0

 51Testing软件测试网:\Qkdoa/d)l

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

4?#Q'm/iH0vQU0

adb shell

*|-v4x9f*e@y/x0

通过上面的命令,就可以进入设备或模拟器的shell环境中,在这个Linux Shell中,你可以执行各种Linux的命令,另外如果只想执行一条shell命令,可以采用以下的方式:51Testing软件测试网b9f.OJ R!{

adb shell [command]

S3K)y8~B c,ak0

如:adb shell dmesg会打印出内核的调试信息。

A.H7I$]/Sb0

 

(y5\1OV&x,c0

3、发布端口:

e,B0O&o^0

你可以设置任意的端口号,做为主机向模拟器或设备的请求端口。如:

1T:Rog-FFFsek0

adb forward tcp:5555 tcp:800051Testing软件测试网)g8rT$`]"jU4hk)N

 51Testing软件测试网%l4gq W"`,~ol

4、复制文件:

1iH8@ VIR~d0

你可向一个设备或从一个设备中复制文件,51Testing软件测试网!o(Xd"a#\_ h2B'[

复制一个文件或目录到设备或模拟器上:51Testing软件测试网l$_OYWA

adb push

;po IQR s.Hd0

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

7iCPB Cxr0

从设备或模拟器上复制一个文件或目录:

Jn5}&hg(j&S0

adb pull51Testing软件测试网GT(Wz hX;f T%P

如:adb pull /addroid/lib/libwebcore.so .51Testing软件测试网^,NG~(T1D0N

 51Testing软件测试网}_o l{2c \ ~

5、搜索模拟器/设备的实例:51Testing软件测试网h"l~#KS]ya

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

adb devices51Testing软件测试网.s:~+N0j-T&r2Wy x

 51Testing软件测试网ts(I-os1_'Zy$F(V

6、查看bug报告:51Testing软件测试网 odr%`-{ c0A Td

adb bugreport51Testing软件测试网/KG [nNUT

 51Testing软件测试网3r?(y EWeuX

7、记录无线通讯日志51Testing软件测试网/b3b d$Q1yPf4L6^w t:o

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

/MT6}.Pb;y@-g_0

adb shell

/W5mQ;m"F]l.w7hfLd0

logcat -b radio51Testing软件测试网h\:Z^voL

 

5sG)|'rrN4_0

8、获取设备的ID和序列号:51Testing软件测试网,~$k:y*j,Ia_k

adb get-product

B)AbKj5A"ae(er6O:o0

adb get-serialno

*U a\s S~0

 51Testing软件测试网7w ~I&p)Ec6N^

9、访问数据库SQLite3

3b9B;M?t(] nR)a_0

adb shell51Testing软件测试网5RpR[8_*E"A

sqlite351Testing软件测试网2P'a2y%HSXX#X)`


TAG: Android android Linux linux

 

评分:0

我来说两句

Open Toolbar