Android Debug Bridge

來源:互聯網
上載者:User

標籤:des   android   style   blog   http   color   io   os   使用   

Android Debug Bridge

  ADB lets you communicate with an emulator instance or connected Android-powered device. ADB is a client-server program that includes three components:

  • A client, which runs on your development machine(運行於開發機上). You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
  • A server, which runs as a background process on your development machine(運行於開發機上). The server manages communication between the client and the adb daemon running on an emulator or device.
  • A daemon, which runs as a background process on each emulator or device instance.

  You can find the adb tool in <sdk>/platform-tools/.

  When you start an adb client, the client first checks whether there is an adb server process already running. If there isn‘t, it starts the server process. When the server starts, it binds to local TCP port 5037 and listens for commands sent from adb clients—all adb clients use port 5037 to communicate with the adb server.

  adb-server使用5037作為介面,接收所有client的請求。

  The server then sets up connections to all running emulator/device instances. It locates emulator/device instances by scanning odd-numbered ports in the range 5555 to 5585, the range used by emulators/devices. Where the server finds an adb daemon, it sets up a connection to that port. Note that each emulator/device instance acquires a pair of sequential ports — an even-numbered port for console connections and an odd-numbered port for adb connections. For example:

  Emulator 1, console: 5554
  Emulator 1, adb: 5555
  Emulator 2, console: 5556
  Emulator 2, adb: 5557
  and so on...

  偶數用於console串連,奇數用於adb串連

  As shown, the emulator instance connected to adb on port 5555 is the same as the instance whose console listens on port 5554.

  Once the server has set up connections to all emulator instances, you can use adb commands to access those instances. Because the server manages connections to emulator/device instances and handles commands from multiple adb clients, you can control any emulator/device instance from any client (or from a script).

Enabling adb Debugging

  In order to use adb with a device connected over USB, you must enable USB debugging in the device system settings, under Developer options.

命令定向

  

  

  -s 的參數使用devices命令來獲得。

Querying for Emulator/Device Instances

  輸入 adb devices後,In response, adb prints this status information for each instance:

  • Serial number — A string created by adb to uniquely identify an emulator/device instance by its console port number. The format of the serial number is <type>-<consolePort>. Here‘s an example serial number: emulator-5554
  • State — The connection state of the instance may be one of the following:
    • offline — the instance is not connected to adb or is not responding.
    • device — the instance is now connected to the adb server. Note that this state does not imply that the Android system is fully booted and operational, since the instance connects to adb while the system is still booting. However, after boot-up, this is the normal operational state of an emulator/device instance.
    • no device — there is no emulator/device connected.

  Here‘s an example showing the devices command and its output:

  

Installing an Application

  

 

參考:http://developer.android.com/tools/help/adb.html

Android Debug Bridge

聯繫我們

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