android之adb

來源:互聯網
上載者:User

一、what is adb?
adb全稱Android Debug Bridge ,就是起到調試橋的作用。通過adb我們可以在Eclipse中通過DDMS來調試Android程式,說白了就是debug工具。adb通過監聽Socket TCP 5554等連接埠讓IDE和Qemu通訊。預設情況下當我們運行Eclipse時adb進程就會自動運行。
adb是一個C/S模式的程式,由三個部分組成:a client,a server and a daemon。其中client和server運行在的development machine上,daemon運行在emulator或裝置上。
adb一般位於<sdk>/platform-tools/目錄下,其中<sdk>是android sdk的安裝目錄。

二、HOWTO
可以在命令列輸入adb命令,用法如下:
adb [-d|-e|-s <serialNumber>] <command>
其中serialNumber用來指定模擬器或裝置。

1、查看emulator或裝置
usage: adb devices
輸出格式:[serialNumber] [state]
eg:
$ adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
emulator-5558 device

2、對指定的emulator或裝置上運行命令
當機器上同時運行有多個emulator或裝置時,我們必須在運行adb命令時指定目標裝置。可以通過-s選項來指定目標。
usage: adb -s <serialNumber> <command>
eg:
adb -s emulator-5556 install helloWorld.apk

3、安裝與卸載應用
可以通過install命令來從development computer安裝一個應用到emulator/device上。
usage: adb install <path_of_apk>

通過uninstall命令可以卸載已經安裝的軟體。
usage: adb uninstall name-of-app-package
其中name-of-app-package是/data/data目錄下的安裝包。

4、發布連接埠
可以設定任意的連接埠號碼,做為主機向模擬器或裝置的請求連接埠。
usage: adb forward tcp:6100 tcp:7100

5、複製檔案
可以複製本地檔案(或目錄)到emulator/device或從emulator/device複製檔案(或目錄)到本地。
computer->emulator/device: adb push <local> <remote>
emulator/device->computer: adb pull <remote> <local>
eg:
adb push foo.txt /sdcard/foo.txt

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.