Android筆記之adb命令解析1,androidadb

來源:互聯網
上載者:User

Android筆記之adb命令解析1,androidadb

由於本人學習Android也挺長時間了,一直把日記記在evernote裡面,由於剛離職比較空閑就打算把evernote裡的日誌一遍遍整理出來發布到網上分享。


要在cmd命令中直接使用adb,需要配置環境變數:目錄XXX\sdk\platform-tools

查看adb -help 協助命令列印出以下內容:

Android Debug Bridge version 1.0.31 <!--安卓調試橋接器 版本號碼:1.0.31-->

-a - directs adb to listen on all interfaces for a connection
<!-- -a 參數,指示adb偵聽串連的所有介面。 -->

-d - directs command to the only connected USB device
returns an error if more than one USB device is present.
<!-- -d 參數,指示命令僅串連USB裝置
如果同時存在多個USB裝置,將會返回一個錯誤。
-->

-e - directs command to the only running emulator.
returns an error if more than one emulator is running.
<!-- -e 參數,指示僅串連運行中的模擬器--
如果超過一個模擬器在運行,將返回一個錯誤。
-->

-s <specific device> - directs command to the device or emulator with the given
serial number or qualifier. Overrides ANDROID_SERIAL environment variable.

<!-- -s <specific device>(給定的裝置) 參數,根據給定的序號或修飾詞<specific device>,命令指定到那個裝置或者模擬器。

覆蓋ANDROID_SERIAL環境變數。
-->

-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.


<!-- -p <product name or path>(產品名稱或路徑) 參數,顯示其產品的名稱,如:"sooner",或者
是一個相對/絕對的產品輸出路徑,如:"out/target/product/sooner"。
如果-p沒有指定的話,就會使用ANDROID_PRODUCT_OUT的環境變數,那必須是一個絕對路徑。

-->

-H - Name of adb server host (default: localhost)

<!-- -H 參數,指示adb 服務主機名 -->

-P - Port of adb server (default: 5037)
<!-- -P 參數,指示adb 服務連接埠號碼 -->

devices [-l] - list all connected devices
('-l' will also list device qualifiers)

<!-- adb devices [-l]通過此命令可以列出所有已經串連的裝置
添加'-l'參數將列出裝置修飾語
eg: adb devices -l
List of devices attached
da0b232e device product:jflteuc model:GT_I9500 device:jflteatt
-->

connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number is specified.

<!-- adb connect <host>[:<port>]通過TCP/IP串連裝置,如果沒有指定連接埠號碼,使用預設5555連接埠。
-->

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.

<!-- adb disconnect [<host>[:<port>]]使用此命令可以去斷開來自TCP/IP的裝置串連,
如果沒有指定連接埠號碼,使用預設5555連接埠。
使用這個命令不添加額外的參數將會斷開所有TCP/IP串連的裝置。
-->

device commands:
<!--裝置命令-->
adb push [-p] <local> <remote>
- copy file/dir to device
('-p' to display the transfer progress)

<!--adb push [-p] <local> <remote>命令:複製一個檔案/目錄到裝置中--
-p 參數指定,顯示傳輸進度
-->

adb pull [-p] [-a] <remote> [<local>]
- copy file/dir from device
('-p' to display the transfer progress)
('-a' means copy timestamp and mode)

<!--adb pull [-p] [-a] <remote> [<local>]命令:從裝置中複製一個檔案/目錄出來
-p 參數指定,顯示傳輸進度
-a 指複製的時間戳記和模式。
-->

adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')

<!--adb sync [ <directory> ]命令:複製主機內容到裝置,僅在裝置內容改變後對其內容進行同步處理操作。
-l 意味著列出但不複製
參考 adb help all 命令。
-->

adb shell - run remote shell interactively
<!--adb shell命令:與遠程shell互動運行。
-->

adb shell <command> - run remote shell command
<!--adb shell <command>命令:運行遠程shell命令

如:adb shell ls -l
-->

adb emu <command> - run emulator console command

<!--adb emu <command>命令:運行模擬器控制台命令
-->

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

<!--adb logcat命令:查看裝置日誌
-->

adb forward --list - list all forward socket connections.
the format is a list of lines with the following format:
<serial> " " <local> " " <remote> "\n"

<!--adb forward --list命令:列出所有轉寄通訊端串連。
這個的格式是一個行列表,格式如下:
<serial> " " <local> " " <remote> "\n"
-->

adb forward <local> <remote> - forward socket connections
forward specs are one of:
<!--adb forward <local> <remote> 命令使用者轉寄PC指定的連接埠<local>到裝置指定的連接埠<remote>。
轉寄socket串連的轉寄規格如下:-->
tcp:<port>
<!--tcp:<連接埠號碼>-->
localabstract:<unix domain socket name>
<!--localabstract:<unix 域通訊端名稱>-->
localreserved:<unix domain socket name>
<!--localreserved:<unix 域通訊端名稱>-->
localfilesystem:<unix domain socket name>
<!--localfilesystem:<unix 域通訊端名稱>-->
dev:<character device name>
<!--dev:<字元裝置名稱>-->
jdwp:<process pid> (remote only)
<!--jdwp:<遠程進程編號>-->
<!--
註:
unix domain socket
參見:http://zh.wikipedia.org/wiki/Unix_domain_socket
jdwp
參見:http://zh.wikipedia.org/wiki/JPDA

1.eg:
adb forward tcp:6100 tcp:7100 // PC上所有6100連接埠通訊資料將被重新導向到手機端/模擬器7100連接埠server上
2.eg:
adb forward tcp:6100 local:logd // PC上所有6100連接埠通訊資料將被重新導向到手機端/模擬器UNIX類型socket上

-->

adb forward --no-rebind <local> <remote>
- same as 'adb forward <local> <remote>' but fails

<!--
如果指定--no-rebind,相同的adb forward <local> <remote>命令 將失敗。
-->

if <local> is already forwarded

<!--如果<local>已經轉寄-->

adb forward --remove <local> - remove a specific forward socket connection

<!--adb forward --remove <local> 移除一個指定的轉寄socket串連-->

adb forward --remove-all - remove all forward socket connections

<!--adb forward --remove-all 移除所有的轉寄socket串連-->

adb jdwp - list PIDs of processes hosting a JDWP transport

<!--adb jdwp 顯示託管在一個jdwp傳輸的進程pid列表-->

adb install [-l] [-r] [-d] [-s] [--algo <algorithm name> --key <hex-encoded ke
y> --iv <hex-encoded iv>] <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
)
('-d' means allow version code downgrade)
('-s' means install on SD card instead of internal storage)
('--algo', '--key', and '--iv' mean the file is encrypted already)

<!--
adb install [-l] [-r] [-d] [-s] [--algo <algorithm name> --key <hex-encoded ke
y> --iv <hex-encoded iv>] <file> 通過這個命令來將打包的APK包檔案安裝到裝置中,
-l 表示鎖定的APP,
-r 表示重新安裝app,保留原來的資料,
-d 表示允許版本代碼降級
-s 表示安裝在SD卡,而不是內部儲存
'--algo', '--key', and '--iv' 表示檔案已經加密
-->


adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories
)

<!--
adb uninstall [-k] <package> 命令,用來刪除安裝在裝置上的APK包,
-k意味著保留資料和緩衝目錄
-->

adb bugreport - return all information from the device that should be included in a bug report.

<!--
adb bugreport 輸出裝置所有資訊,包含在缺陷報告中。
-->

adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-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.)
(-obb|-noobb enable/disable backup of any installed apk expansion
(aka .obb) files associated with each application; the default is noobb.)
(-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.)

<!--adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all]
[-system|-nosystem] [<packages...>]將裝置的資料寫入的一個歸檔檔案<file>中(PC目錄檔案)。
如果沒有提供-f選項,資料將寫入到目前的目錄的backup.ab檔案中。
-apk|-noapk 啟用/禁用 備份自己的apk檔案到歸檔檔案中。預設禁用。
-obb|-noobb 啟用/禁用 備份與每個應用程式關聯的任何安裝的apk擴充檔案(又名.obb檔案(opaque binary blobs))
-shared|-noshared 啟用/禁用 裝置共用儲存/SD 記憶卡內容備份。預設禁用。
-all 備份所有安裝的應用。-all 預設自動包含系統應用。
-system|-nosystem 指定是否切換包含系統應用。預設為包含系統應用。
<packages...> 需要備份的應用程式列表
如果已經使用 -all 或 -shared 標記,那麼包列表<packages...>是可選的。
應用程式顯式的包含在命令列中,即使 -nosystem標記指定忽略系統應用。
-->

adb restore <file> - restore device contents from the <file> backup archive
<!--adb restore <file>通過備份的歸檔檔案恢複裝置內容-->
adb help - show this help message
<!--adb help顯示adb協助資訊-->
adb version - show version num
<!--adb version顯示adb版本號碼-->

scripting:
<!--指令碼-->
adb wait-for-device - block until device is online
<!--adb wait-for-device 等待直到裝置線上-->

adb start-server - ensure that there is a server running
<!--adb start-server 確保服務已經運行-->

adb kill-server - kill the server if it is running
<!--adb kill-server 殺死運行中的服務-->

adb get-state - prints: offline | bootloader | device
<!--adb get-state 列印裝置的狀態:offline | bootloader | device-->

adb get-serialno - prints: <serial-number>
<!--adb get-serialno 列印裝置序號資訊-->

adb get-devpath - prints: <device-path>
<!--adb get-devpath 列印裝置路徑-->

adb status-window - continuously print device status for a specified device
<!--adb status-window 連續列印指定的裝置狀態-->

adb remount - remounts the /system partition on the device read-write
<!--adb remount 對其裝置系統磁碟分割讀寫進行重新掛載-->

adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
<!--adb reboot 重啟裝置,可選進入引導程式或者恢複程式。 -->

adb reboot-bootloader - reboots the device into the bootloader
<!--adb reboot-bootloader 重啟裝置,進入引導程式(刷機模式)。 -->

adb root - restarts the adbd daemon with root permissions
<!--adb root重新啟動adbd後台進程獲得ROOT許可權-->

adb usb - restarts the adbd daemon listening on USB
<!--adb usb重新啟動adbd後台進程監聽USB-->

adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port
<!--adb tcpip <port>重新啟動adbd後台進程,來監聽指定的TCP連接埠-->

networking:
<!--網路-->
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. default route 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.


<!--
adb ppp <tty> [parameters] - 在USB上啟動並執行PPP。

注意:你不能自動啟動PPP串連。

<tty>指的tty為PPP流。例如。dev:/dev/omap_csmi_tty1[parameters]
- 例如。預設路由調試丟棄本地notty usepeerdns

adb sync notes: adb sync [ <目錄> ]

<localdir> 可以有幾種方式解釋:

- 如果沒有指定<directory><目錄> /system 和 /data分區將被更新。

- 如果它是"system" 或 "data" ,只有對應的分區被更新。

-->

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
<!--
ADB_TRACE環境變數 -列印調試資訊。使用逗號分隔,列出下列一個或者全部: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_SERIAL - 串連到的序號。 假如給定-s參數,它的優先順序將高於這個環境變數。-->

ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed.
<!--ANDROID_LOG_TAGS環境變數,-當使用logcat的選項,只有這些調試標籤會被列印出來。-->

官方adb工具相關文檔可以參見:
http://developer.android.com/tools/help/adb.html

 

作者:sufish
出處:http://www.cnblogs.com/dotnetframework/

本文著作權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文串連。如有問題,可以郵件:dotnetframework@sina.com聯絡我,非常感謝。 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.