做了這么長時間的開發(fā)與管理,在命令上總是自見則過,往往卻忽視了在其命令上的分享過程,所以現(xiàn)在稍微有點時間就把 其命令的相關(guān)操作來簡單的掃盲一番吧,也系統(tǒng)通過這種方式去授之以漁而不是魚,好了,我以圖解的方式來展示,當(dāng)然我的習(xí)慣就是任何東西先看幫助文檔或者命令,就今天我們這里要講解的ADB命令在命令行中可以通過命令幫助來進行詳細了解,廢話不多說,先上圖吧:




以上為使用help來顯示其相關(guān)的命令使用說明,當(dāng)然那個如果你的英文足夠好的話,其實這些都很簡單,當(dāng)然,如你不太習(xí)慣去看這些英文描述的話,那接下來就由我來幫助處理這樣的問題吧,好了,我就以最初始的理解方式來進行翻譯與講解吧,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
通過這個直接的命令僅僅是去連接USB設(shè)備
returns an error if more than one USB device is present.
如果有多個USB設(shè)備同時出現(xiàn)的時候就會返回一個錯誤信息
-e - directs command to the only running emulator.
直接使用這個命令符號來運行模擬器
returns an error if more than one emulator is running.
如果存在多個模擬器同時運行時會在當(dāng)前返回一個錯誤信息
-s <serial number> - directs command to the USB device or emulator with
the given serial number. Overrides ANDROID_SERIAL
environment variable.
通過這個直接的命令去展示其USB設(shè)備或者模擬器的序列號,彼此覆蓋時會使其環(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.
通過此命令顯示其產(chǎn)品的名稱,如"sooner",或者是相對與絕對的產(chǎn)品輸出路徑像"out/target/product/sooner",如果 -p沒有指定的話,就會使用ANDROID_PRODUCT_OUT的環(huán)境變量,但必須是一個絕對路徑.
devices - list all connected devices
通過此命令可以列出所有已經(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.
通過TCP/IP的默認端口5555來連接設(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.
使用此命令可以去斷開來自TCP/IP的設(shè)備連接,其在沒有指定端口號時默認指定為5555,使用這個命令不需要去增加參數(shù)將會斷開來自TCP/IP的所有連接設(shè)備
device commands:
設(shè)備命令:
adb push <local> <remote> - copy file/dir to device
PUSH命令:即復(fù)制一個文件或者目錄進設(shè)備中
adb pull <remote> [<local>] - copy file/dir from device
PULL命令:即復(fù)制一個文件或者目錄進設(shè)備中
adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')
SYNC:復(fù)制主機內(nèi)容進設(shè)備,僅僅是設(shè)備進行改變時對其內(nèi)容進行同步處理的操作,括號里有說明:我的意思是列出但是不需要復(fù)制,可參考幫助ALL
adb shell - run remote shell interactively
SHELL:運行遠程SHELL與之交互
adb shell <command> - run remote shell command
SHELL:直接運行遠程SHELL命令
adb emu <command> - run emulator console command
EMU:運行模擬器監(jiān)控信息面板命令
adb logcat [ <filter-spec> ] - View device log
閱覽設(shè)備日志
adb forward <local> <remote> - forward socket connections
遠期套接字連接
forward specs are one of:
遠期規(guī)格顯示的一個標(biāo)準(zhǔn)是:
tcp:<port>
TCP端口號
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)
遠程進程ID
adb jdwp - list PIDs of processes hosting a JDWP transport
列出相關(guān)的進程ID為主機進程的一個JAVA調(diào)試的無線協(xié)議的傳輸
說道JDWP,我簡單對其說明下,說明是JDWP呢,JDWP的全寫是:Java Debug Wire Protocol:即JAVA調(diào)試器無線協(xié)議,它定義了調(diào)試器(Debugger)和被調(diào)試的JAVA虛擬機(target vm)之間的通信協(xié)議,在這里,我更要說明下:Debugger與Target vm,Target vm 中運行著我們希望要調(diào)試的程序,它與一般運行的 Java 虛擬機沒有什么區(qū)別,只是在啟動時加載了 Agent JDWP 從而具備了調(diào)試功能。而 debugger 就是我們熟知的調(diào)試器,它向運行中的 target vm 發(fā)送命令來獲取 target vm 運行時的狀態(tài)和控制 Java 程序的執(zhí)行。Debugger 和 target vm 分別在各自的進程中運行,他們之間的通信協(xié)議就是 JDWP。JDWP 與其他許多協(xié)議不同,它僅僅定義了數(shù)據(jù)傳輸?shù)母袷?,但并沒有指定具體的傳輸方式。這就意味著一個 JDWP 的實現(xiàn)可以不需要做任何修改就正常工作在不同的傳輸方式上(在 JDWP 傳輸接口中會做詳細介紹)。JDWP 是語言無關(guān)的。理論上我們可以選用任意語言實現(xiàn) JDWP。然而我們注意到,在 JDWP 的兩端分別是 target vm 和 debugger。Target vm 端,JDWP 模塊必須以 Agent library 的形式在 Java 虛擬機啟動時加載,并且它必須通過 Java 虛擬機提供的 JVMTI 接口實現(xiàn)各種 debug 的功能,所以必須使用 C/C++ 語言編寫。而 debugger 端就沒有這樣的限制,可以使用任意語言編寫,只要遵守 JDWP 規(guī)范即可。JDI(Java Debug Interface)就包含了一個 Java 的 JDWP debugger 端的實現(xiàn)(JDI 將在該系列的下一篇文章中介紹),JDK 中調(diào)試工具 jdb 也是使用 JDI 完成其調(diào)試功能的。以上介紹的 JDWP agent在調(diào)試中扮演的角色為下圖所示:

其實我們對其協(xié)議簡單分析下,我們可以通過下圖來了解到起握手協(xié)議的簡單過程:

最后了解下其架構(gòu)吧:

好,從以上我們了解了其JDWP的相關(guān)信息,更詳細的信息與操作請在GOOGLE里詳細查詢與了解吧.
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)
通過這個命令來對其打包的APK進行安裝進設(shè)備中,-l意味著遠期鎖定期APP,-r意味著需要重新安裝這個APP,當(dāng)然需要對其數(shù)據(jù)進行保持,-s意味著安裝進SD卡中
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories)
通過這個命令來卸載其安裝好的APK,即移除當(dāng)前的APP來自設(shè)備的包,-k意味著保持數(shù)據(jù)域緩存目錄
adb bugreport - return all information from the device
that should be included in a bug report.
通過這個命令可以對其調(diào)試出的信息(設(shè)備的信息)輸出并顯示出來
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.)
通過這個命令可以實現(xiàn)其內(nèi)容備份,
adb restore <file> - restore device contents from the <file> backup archive
對其備份的歸檔文件可以重新對其內(nèi)容進行設(shè)備的存儲
adb help - show this help message
顯示幫助信息
adb version - show version num
顯示去版本號
scripting:
腳本
adb wait-for-device - block until device is online
等待期設(shè)備知道設(shè)備在線時
adb start-server - ensure that there is a server running
啟動其服務(wù)
adb kill-server - kill the server if it is running
對其運行了的服務(wù)通過此命令對其殺死
adb get-state - prints: offline | bootloader | device
獲得其設(shè)備的狀態(tài)
adb get-serialno - prints: <serial-number>
獲得一系列的序列號信息
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
對其設(shè)備讀寫進行重新安裝
adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
重新加載或者是去恢復(fù)程序等
adb reboot-bootloader - reboots the device into the bootloader
對其重新啟動的設(shè)備進行加載
adb root - restarts the adbd daemon with root permissions
重新啟動后獲得ROOT權(quán)限
adb usb - restarts the adbd daemon listening on USB
重新啟動來監(jiān)聽器USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port
重新啟動TCP來監(jiān)聽指定的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.
以上部分由于時間問題就不翻譯與理解了,其實后面幾句都非常好理解,自己也嘗試著去做一下吧,
下面就進行一個簡單的例子:
顯示日志: adb logcat | more

列出設(shè)備: adb devices

OK,以上是簡單的兩個命令列子,你自己可以根據(jù)實際情況去帶入相關(guān)參數(shù)即可對其命令進行校驗了,好了,希望能給大家做一定的參考與學(xué)習(xí).......
url:http://greatverve.cnblogs.com/archive/2012/04/23/android-adb.html