- The Android Game Developer's Handbook
- Avisekhar Roy
- 684字
- 2021-07-14 10:28:59
Android Debug Bridge
Android Debug Bridge (adb) is a tool used to establish communication between the development environment and a virtual device or the connected Android device. It is a client-server command-line program, which works on three elements:
- Client on the development machine: Works as the client, which can be invoked by adb commands. Other Android tools such as the ADT plugin and DDMS also create adb clients.
- Daemon: A background process that runs in the background on each emulator or device instance.
- Server on the development machine: This is a background process that runs on the development machine and manages the communication between the client and server.
On starting adb, 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 the local TCP port 5037
and listens for commands sent from adb clients—all adb clients use port 5037
to communicate with the adb server.
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.
Once the server has set up connections to all emulator instances, the developer can use adb commands to access those instances. Because the server manages connections to emulator/device instances, and handles commands from multiple adb clients, the developer can control any emulator/device instance from any client (or from a script).
Using adb on an Android device
One of the first things to remember is to put the development device in the USB debugging mode. This can be done by navigating to Settings, tapping on Developer options, and checking the box named USB debugging for Android 5.0 and above (for other Android versions, refer to https://www.recovery-android.com/enable-usb-debugging-on-android.html). Without doing this, the development PC won't recognize the device.
The most important thing to know is simply how to get to the adb folder via the command line. This is done with the cd
(change directory) command. So, if (on Windows) the SDK folder is called android-SDK
, and it's in the root (c:
) directory, you can enter the following command:
cd c:/android-SDK
Then, to get into the adb folder, use this:
cd platform-tools
At this point, the prompt will say this:
C:\android-SDK\platform-tools>
Now the developer can connect the device, and test the adb connection, after locating and installing the drivers for a particular device:
adb devices
If everything is set up properly, there should be a list of devices attached. The phone or tablet will have a number assigned to it, so don't be surprised if it doesn't say "Droid Razr" or "Galaxy Nexus".
For average users, adb is more of a tool for basic hacking tasks than it is a task in itself. Unless the developers know what they are doing, they probably shouldn't go poking around too much without clear instructions. When rooting the device, knowing these basics can help save some time and let the developer be prepared in advance.
Beside the specific instructions to root a particular device, the next thing the developer needs will be the drivers for the phone or tablet.
The easiest way to do this is usually to simply Google search for the specific device plus drivers. So if the developer has a Droid Razr, he/she should search for Droid Razr Windows Drivers
. This will almost always direct the developer to the best link.
Another option, which will only work for stock Android devices, is to download the USB drivers from the SDK. To do this, launch the SDK manager again. Go to the Available packages tab on the left, expand the Third party add-ons entry, and then expand the Google Inc. add-ons entry. Finally, check the entry for the Google USB Driver package.
Note that the USB driver package isn't compatible with OS X.
- Embedded Linux Projects Using Yocto Project Cookbook
- Docker進階與實戰
- 新一代通用視頻編碼H.266/VVC:原理、標準與實現
- NLTK基礎教程:用NLTK和Python庫構建機器學習應用
- 信息安全技術
- Oracle從入門到精通(第5版)
- Learning Concurrent Programming in Scala
- Spring Boot+MVC實戰指南
- Image Processing with ImageJ
- Unity Character Animation with Mecanim
- Visual Basic程序設計基礎
- 企業級Java現代化:寫給開發者的云原生簡明指南
- Tkinter GUI Programming by Example
- Web前端開發精品課:HTML5 Canvas開發詳解
- HTML5+jQuery Mobile移動應用開發