The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.
Several chapters in this book offer
adb recipes for doing
certain things at the command line. Having the
adb binary in
PATH environment variable for your development machine is very
handy, so you can run such commands from anywhere.
However, those other chapters only skim the surface of what sorts
adb commands there are and what they can be used for. Several
others are presented here.
Understanding this chapter requires that you have read the core chapters of this book, and that you know how to work on the command line.
adb works well, except when there is more than one visible Android
environment, such as two devices, or a device and an emulator. Some
commands — notably
adb devices — work normally. Most other
commands will complain that
adb does not know which of the Android
environments the command is supposed to act upon.
There are three switches you can include after
adb and before
the command that control what
adb will use:
-dsays “use the device, there should only be one” (and if there is more than one, you get an error)
-esays “use the emulator, there should only be one” (and if there is more than one, you get an error)
-s ...says “use the environment whose serial number is
That serial number is the value given in the
adb devices command.
For an actual device, the serial number usually is the real serial number.
For an emulator, the serial number is
the value before the AVD name in the title bar of the emulator window.
Frequently, that value starts with
5554 and increments by two
for each subsequent running emulator. Hence,
-e is roughly equivalent
The preview of this section is en route to Mars.
The preview of this section may contain nuts.
The preview of this section is in the process of being translated from its native Klingon.
The preview of this section was eaten by a grue.
The preview of this section was accidentally identified as an Android 'tasty treat' by the Cookie Monster.