adb的相關命令集:
Android Debug Bridge version 1.0.26 - #當升級 Android SDK 後,ADB 也會隨之升級。
adb [-d|-e|-s {<serialNumber>}] shell
-d
- EN directs command to the only connected USB device returns an error if more than one USB device is present.
- CHS 該操作只針對已經通過 USB 鏈接的移動設備,如果鏈接一臺以上的移動設備會返回一個錯誤。
-e
- EN directs command to the only running emulator. returns an error if more than one emulator is running.
- CHS 該操作只針對模擬器,如果同時運行的模擬器數量大於一,會返回一個錯誤。
-s <serial number>
- EN directs command to the USB device or emulator with the given serial number. Overrides ANDROID_SERIAL environment variable.
- CHS 該操作針對 USB 鏈接的設備 或 給定編號的模擬器,複寫 serial number 爲要操作的模擬器編號。
-p <product name or path>
- EN 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.
- CHS 該操作針對 設備的名稱 或 設備相對/絕對的路徑, 如果未把設備的加入環境變量,必須給定一個絕對路徑。
devices
- EN list all connected devices
- CHS 列出所有已經鏈接或啓動的設備清單
connect <host>[:<port>]
- EN connect to a device via TCP/IP Port 5555 is used by default if no port number is specified.
- CHS 如果 connect 後面未賦值, 通過 TCP/IP 5555 端口鏈接設備。
disconnect [<host>[:<port>]]
- EN disconnect from a TCP/IP device. Port 5555 is used by default if no port number is specified. Using this ocmmand with no additional arguments will disconnect from all connected TCP/IP devices.
- CHS 如果 disconnect 後面未賦值,斷開 TCP/IP 5555 端口上的設備,也可以使用 ocmmand
參數斷開所有已經鏈接的設備。
device commands: #針對設備的命令
adb push <local> <remote>
- EN copy file/dir to device
- CHS 複製 文件/目錄 到設備
adb pull <remote> [<local>]
- EN copy file/dir from device
- CHS 從設備複製 文件/目錄
adb sync [ <directory> ]
- EN copy host->device only if changed (-l means list but don't copy) (see 'adb help all')
- CHS 同步目錄 該操作只針對 主機->設備 上的同步, 如果後面加 -l
意思爲只羅列不復制。
adb shell
- EN run remote shell interactively
- CHS 運行交互式 shell 腳本 (和 Linux, Unix 有區別,微型操作基本相同)
adb shell <command>
- EN run remote shell command
- CHS 運行 shell 腳本 command 爲參數
adb emu <command>
- EN run emulator console command
- CHS 運行模擬器控制檯命令
adb logcat [ <filter-spec> ]
- EN View device log
- CHS 查看設備日誌 (Eclipse logcat)
adb forward <local> <remote>
- EN forward socket connections forward specs are one of:
- CHS 從本地的 socket 鏈接轉移到特定的一個移動設備,參數如下:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp
- EN list PIDs of processes hosting a JDWP transport
- CHS 羅列 PIDs 進程寄宿 JDWP 傳輸
adb install [-l] [-r] [-s] <file>
- EN push this package file to the device and install it
- CHS 給設備安裝軟件
('-l' means forward-lock the app) #鎖定該程序
('-r' means reinstall the app, keeping its data) #重新安裝該程序,保存數據
('-s' means install on SD card instead of internal storage) #安裝在SD卡內,而不是設備內部存儲
adb uninstall [-k] <package>
- EN remove this app package from the device
- CHS 從設備刪除程序包
('-k' means keep the data and cache directories) #不刪除程序運行所產生的數據和緩存目錄(如軟件的數據庫文件)
adb bugreport
- EN return all information from the device that should be included in a bug report.
- CHS 返回所有的設備運行信息包括錯誤報告
adb help
- EN show this help message
- CHS 顯示幫助信息
adb version
- EN show version num
- CHS 顯示 adb 版本
DATAOPTS: #數據操作
(no option) - don't touch the data partition
- CHS 請勿隨意操作數據分區
-w
- EN wipe the data partition
- CHS 擦拭數據分區
-d
- EN flash the data partition
- CHS 針對閃存
scripting: #腳本
adb wait-for-device
- EN block until device is online
- CHS 等待設備鏈接
adb start-server
- EN ensure that there is a server running
- CHS 確保在一個服務器上運行
adb kill-server
- EN kill the server if it is running
- CHS 阻止設備與服務器之間的鏈接
adb get-state
- EN prints: offline | bootloader | device
- CHS 打印設備當前的狀態 |脫機關機|引導狀態|運行狀態
adb get-serialno
- EN prints: <serial-number>
- CHS 打印序列號
adb status-window
- EN continuously print device status for a specified device
- CHS 在該終端持續打印設備狀態
adb remount
- EN remounts the /system partition on the device read-write
- CHS 重新掛載系統分區獲取設備的讀寫權限
adb reboot [bootloader|recovery]
- EN reboots the device, optionally into the bootloader or recovery program
- CHS 重啓啓動設備,後面兩個參數爲引導程序和恢復程序
adb reboot-bootloader
- EN reboots the device into the bootloader
- CHS 重啓設備進入引導程序
adb root
- EN restarts the adbd daemon with root permissions
- CHS 重新獲取 adbd 宿主的管理員權限
adb usb
- EN restarts the adbd daemon listening on USB
- CHS 在USB端口,重新獲取 adbd 宿主
adb tcpip <port>
- EN restarts the adbd daemon listening on TCP on the specified port
- CHS 在制定 TCP/IP 端口,重新獲取 adbd 宿主
networking: #網絡
adb ppp
<tty> [parameters]
- EN 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
- CHS 運行 PPP 在 USB 端口。 注意:你不能自動控制開始一個PPP鏈接。 <tty> 是指電報打印機所出的聲音流。
EN 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.
- CHS adb 同步注意事項: adb sync [ <目錄> ] <本地目錄> 可以解釋爲幾種方法:
- 如果 <目錄> 未指定,那麼 /system 和 /data 磁盤都會更新
- 指定 "system" 或 "data" 那麼只有指定磁盤會更新
environmental variables: #環境變量
ADB_TRACE
- EN Print debug information. A comma separated list of the following values 1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
- CHS 打印調試信息。使用都好隔開下面的一個或多個值,獲取想要得到調試數據
adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
ANDROID_SERIAL
- EN The serial number to connect to. -s takes priority over this if given.
ANDROID_LOG_TAGS
- EN When used with the logcat option, only these debug tags are printed.