做了這么長(zhǎng)時(shí)間的開(kāi)發(fā)與管理,在命令上總是自見(jiàn)則過(guò),往往卻忽視了在其命令上的分享過(guò)程,所以現(xiàn)在稍微有點(diǎn)時(shí)間就把 其命令的相關(guān)操作來(lái)簡(jiǎn)單的掃盲一番吧,也系統(tǒng)通過(guò)這種方式去授之以漁而不是魚(yú),好了,我以圖解的方式來(lái)展示,當(dāng)然我的習(xí)慣就是任何東西先看幫助文檔或者命令,就今天我們這里要講解的ADB命令在命令行中可以通過(guò)命令幫助來(lái)進(jìn)行詳細(xì)了解,廢話不多說(shuō),先上圖吧:
以上為使用help來(lái)顯示其相關(guān)的命令使用說(shuō)明,當(dāng)然那個(gè)如果你的英文足夠好的話,其實(shí)這些都很簡(jiǎn)單,當(dāng)然,如你不太習(xí)慣去看這些英文描述的話,那接下來(lái)就由我來(lái)幫助處理這樣的問(wèn)題吧,好了,我就以最初始的理解方式來(lái)進(jìn)行翻譯與講解吧,OK:
Android Debug Bridge version 1.0.29
這是關(guān)于Android調(diào)試牌的1.0.29版本
-d - directs command to the only connected USB device
通過(guò)這個(gè)直接的命令僅僅是去連接USB設(shè)備
returns an error if more than one USB device is present.
如果有多個(gè)USB設(shè)備同時(shí)出現(xiàn)的時(shí)候就會(huì)返回一個(gè)錯(cuò)誤信息
-e - directs command to the only running emulator.
直接使用這個(gè)命令符號(hào)來(lái)運(yùn)行模擬器
returns an error if more than one emulator is running.
如果存在多個(gè)模擬器同時(shí)運(yùn)行時(shí)會(huì)在當(dāng)前返回一個(gè)錯(cuò)誤信息
-s <serial number> - directs command to the USB device or emulator with
the given serial number. Overrides ANDROID_SERIAL
environment variable.
通過(guò)這個(gè)直接的命令去展示其USB設(shè)備或者模擬器的序列號(hào),彼此覆蓋時(shí)會(huì)使其環(huán)境變量是可變的
-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.
通過(guò)此命令顯示其產(chǎn)品的名稱,如"sooner",或者是相對(duì)與絕對(duì)的產(chǎn)品輸出路徑像"out/target/product/sooner",如果 -p沒(méi)有指定的話,就會(huì)使用ANDROID_PRODUCT_OUT的環(huán)境變量,但必須是一個(gè)絕對(duì)路徑.
devices - list all connected devices
通過(guò)此命令可以列出所有已經(jīng)連接的設(shè)備
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number is specified.
通過(guò)TCP/IP的默認(rèn)端口5555來(lái)連接設(shè)備
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.
使用此命令可以去斷開(kāi)來(lái)自TCP/IP的設(shè)備連接,其在沒(méi)有指定端口號(hào)時(shí)默認(rèn)指定為5555,使用這個(gè)命令不需要去增加參數(shù)將會(huì)斷開(kāi)來(lái)自TCP/IP的所有連接設(shè)備
device commands:
設(shè)備命令:
adb push <local> <remote> - copy file/dir to device
PUSH命令:即復(fù)制一個(gè)文件或者目錄進(jìn)設(shè)備中
adb pull <remote> [<local>] - copy file/dir from device
PULL命令:即復(fù)制一個(gè)文件或者目錄進(jìn)設(shè)備中
adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')
SYNC:復(fù)制主機(jī)內(nèi)容進(jìn)設(shè)備,僅僅是設(shè)備進(jìn)行改變時(shí)對(duì)其內(nèi)容進(jìn)行同步處理的操作,括號(hào)里有說(shuō)明:我的意思是列出但是不需要復(fù)制,可參考幫助ALL
adb shell - run remote shell interactively
SHELL:運(yùn)行遠(yuǎn)程SHELL與之交互
adb shell <command> - run remote shell command
SHELL:直接運(yùn)行遠(yuǎn)程SHELL命令
adb emu <command> - run emulator console command
EMU:運(yùn)行模擬器監(jiān)控信息面板命令
adb logcat [ <filter-spec> ] - View device log
閱覽設(shè)備日志
adb forward <local> <remote> - forward socket connections
遠(yuǎn)期套接字連接
forward specs are one of:
遠(yuǎn)期規(guī)格顯示的一個(gè)標(biāo)準(zhǔn)是:
tcp:<port>
TCP端口號(hào)
localabstract:<unix domain socket name>
本地抽象:UNIX域名的SOCKET名稱
localreserved:<unix domain socket name>
本地服務(wù):UNIX域名/SOCKET名稱
localfilesystem:<unix domain socket name>
本地文件系統(tǒng):UNIX域名/SOCKET名稱
dev:<character device name>
設(shè)備:字符設(shè)備名稱
jdwp:<process pid> (remote only)
遠(yuǎn)程進(jìn)程ID
adb jdwp - list PIDs of processes hosting a JDWP transport
列出相關(guān)的進(jìn)程ID為主機(jī)進(jìn)程的一個(gè)JAVA調(diào)試的無(wú)線協(xié)議的傳輸
說(shuō)道JDWP,我簡(jiǎn)單對(duì)其說(shuō)明下,說(shuō)明是JDWP呢,JDWP的全寫(xiě)是:Java Debug Wire Protocol:即JAVA調(diào)試器無(wú)線協(xié)議,它定義了調(diào)試器(Debugger)和被調(diào)試的JAVA虛擬機(jī)(target vm)之間的通信協(xié)議,在這里,我更要說(shuō)明下:Debugger與Target vm,Target vm 中運(yùn)行著我們希望要調(diào)試的程序,它與一般運(yùn)行的 Java 虛擬機(jī)沒(méi)有什么區(qū)別,只是在啟動(dòng)時(shí)加載了 Agent JDWP 從而具備了調(diào)試功能。而 debugger 就是我們熟知的調(diào)試器,它向運(yùn)行中的 target vm 發(fā)送命令來(lái)獲取 target vm 運(yùn)行時(shí)的狀態(tài)和控制 Java 程序的執(zhí)行。Debugger 和 target vm 分別在各自的進(jìn)程中運(yùn)行,他們之間的通信協(xié)議就是 JDWP。JDWP 與其他許多協(xié)議不同,它僅僅定義了數(shù)據(jù)傳輸?shù)母袷?,但并沒(méi)有指定具體的傳輸方式。這就意味著一個(gè) JDWP 的實(shí)現(xiàn)可以不需要做任何修改就正常工作在不同的傳輸方式上(在 JDWP 傳輸接口中會(huì)做詳細(xì)介紹)。JDWP 是語(yǔ)言無(wú)關(guān)的。理論上我們可以選用任意語(yǔ)言實(shí)現(xiàn) JDWP。然而我們注意到,在 JDWP 的兩端分別是 target vm 和 debugger。Target vm 端,JDWP 模塊必須以 Agent library 的形式在 Java 虛擬機(jī)啟動(dòng)時(shí)加載,并且它必須通過(guò) Java 虛擬機(jī)提供的 JVMTI 接口實(shí)現(xiàn)各種 debug 的功能,所以必須使用 C/C++ 語(yǔ)言編寫(xiě)。而 debugger 端就沒(méi)有這樣的限制,可以使用任意語(yǔ)言編寫(xiě),只要遵守 JDWP 規(guī)范即可。JDI(Java Debug Interface)就包含了一個(gè) Java 的 JDWP debugger 端的實(shí)現(xiàn)(JDI 將在該系列的下一篇文章中介紹),JDK 中調(diào)試工具 jdb 也是使用 JDI 完成其調(diào)試功能的。以上介紹的 JDWP agent在調(diào)試中扮演的角色為下圖所示:
其實(shí)我們對(duì)其協(xié)議簡(jiǎn)單分析下,我們可以通過(guò)下圖來(lái)了解到起握手協(xié)議的簡(jiǎn)單過(guò)程:
最后了解下其架構(gòu)吧:
好,從以上我們了解了其JDWP的相關(guān)信息,更詳細(xì)的信息與操作請(qǐng)?jiān)贕OOGLE里詳細(xì)查詢與了解吧.
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)
通過(guò)這個(gè)命令來(lái)對(duì)其打包的APK進(jìn)行安裝進(jìn)設(shè)備中,-l意味著遠(yuǎn)期鎖定期APP,-r意味著需要重新安裝這個(gè)APP,當(dāng)然需要對(duì)其數(shù)據(jù)進(jìn)行保持,-s意味著安裝進(jìn)SD卡中
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories)
通過(guò)這個(gè)命令來(lái)卸載其安裝好的APK,即移除當(dāng)前的APP來(lái)自設(shè)備的包,-k意味著保持?jǐn)?shù)據(jù)域緩存目錄
adb bugreport - return all information from the device
that should be included in a bug report.
通過(guò)這個(gè)命令可以對(duì)其調(diào)試出的信息(設(shè)備的信息)輸出并顯示出來(lái)
adb backup [-f <file>] [-apk|-noapk] [-shared|-noshared] [-all] [-system|-nosystem] [<packages...>]
- write an archive of the device's data to <file>.
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.)
(-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)
(<packages...> 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.)
通過(guò)這個(gè)命令可以實(shí)現(xiàn)其內(nèi)容備份,
adb restore <file> - restore device contents from the <file> backup archive
對(duì)其備份的歸檔文件可以重新對(duì)其內(nèi)容進(jìn)行設(shè)備的存儲(chǔ)
adb help - show this help message
顯示幫助信息
adb version - show version num
顯示去版本號(hào)
scripting:
腳本
adb wait-for-device - block until device is online
等待期設(shè)備知道設(shè)備在線時(shí)
adb start-server - ensure that there is a server running
啟動(dòng)其服務(wù)
adb kill-server - kill the server if it is running
對(duì)其運(yùn)行了的服務(wù)通過(guò)此命令對(duì)其殺死
adb get-state - prints: offline | bootloader | device
獲得其設(shè)備的狀態(tài)
adb get-serialno - prints: <serial-number>
獲得一系列的序列號(hào)信息
adb status-window - continuously print device status for a specified device
連續(xù)打印指定的設(shè)備狀態(tài)
adb remount - remounts the /system partition on the device read-write
對(duì)其設(shè)備讀寫(xiě)進(jìn)行重新安裝
adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
重新加載或者是去恢復(fù)程序等
adb reboot-bootloader - reboots the device into the bootloader
對(duì)其重新啟動(dòng)的設(shè)備進(jìn)行加載
adb root - restarts the adbd daemon with root permissions
重新啟動(dòng)后獲得ROOT權(quán)限
adb usb - restarts the adbd daemon listening on USB
重新啟動(dòng)來(lái)監(jiān)聽(tīng)器USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port
重新啟動(dòng)TCP來(lái)監(jiān)聽(tīng)指定的TCP端口
networking:
網(wǎng)絡(luò)
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should 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.
以上部分由于時(shí)間問(wèn)題就不翻譯與理解了,其實(shí)后面幾句都非常好理解,自己也嘗試著去做一下吧,
下面就進(jìn)行一個(gè)簡(jiǎn)單的例子:
顯示日志: adb logcat | more
列出設(shè)備: adb devices
OK,以上是簡(jiǎn)單的兩個(gè)命令列子,你自己可以根據(jù)實(shí)際情況去帶入相關(guān)參數(shù)即可對(duì)其命令進(jìn)行校驗(yàn)了,好了,希望能給大家做一定的參考與學(xué)習(xí).......
url:http://greatverve.cnblogs.com/archive/2012/04/23/android-adb.html
聯(lián)系客服