Appendix B. ADB: The Android Debug Bridge

image with no caption

In this book, we’ve focused on using an IDE for all your Android needs. But there are times when using a command-line tool can be plain useful, like those times when Android Studio can’t see your Android device but you just know it’s there. In this chapter, we’ll introduce you to the Android Debug Bridge (or adb), a command-line tool you can use to communicate with the emulator or Android devices.

adb: your command-line pal

Every time your development machine needs to talk to an Android device, whether it’s a real device connected with a USB cable, or a virtual device running in an emulator, it does it by using the Android Debug Bridge (adb). The adb is a process that’s controlled by a command that’s also called adb.

The adb command is stored in the platform-tools directory of the Android System Developer’s Kit. On a Mac, you’ll probably find it in /Users/<username>/Library/Android/sdk/platform-tools. If you add the platform-tools directory to your PATH, you will be able to run adb from the command line.

In a terminal or at a command prompt, you can use it like this:

image with no caption

The adb devices command means “Tell me which Android devices you are connected to”. The adb command works by talking to an adb server process, which runs in the background. The adb server ...

Get Head First Android Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.