Skip to content
Latchkey

adb devices: List Attached Android Devices in CI

adb devices prints one line per connected device or emulator with its serial and state (device, offline, or unauthorized).

On a CI runner the first question is always whether the emulator is actually up. adb devices answers it, and its states tell you why an install or test step will fail before it runs.

What it does

adb devices queries the adb server for every attached target and prints its serial number and connection state. A state of device means ready; offline means the daemon is still booting; unauthorized means the host key was not accepted. adb starts a background server on first use.

Common usage

Terminal
adb devices              # short list
adb devices -l           # include model/product/transport
adb start-server         # explicitly start the daemon
adb -s emulator-5554 shell getprop sys.boot_completed

Options

Flag / subcommandWhat it does
-lLong output: also show product, model, and transport id
-s <serial>Target a specific device when several are attached
start-server / kill-serverStart or stop the background adb daemon
wait-for-deviceBlock until a device reaches the device state
-e / -dTarget the sole emulator (-e) or sole USB device (-d)

In CI

Never assume the emulator is ready the moment the launch command returns. Chain adb wait-for-device and then poll getprop sys.boot_completed until it returns 1, otherwise install and instrumentation steps race the boot.

Common errors in CI

"error: no devices/emulators found" means no target reached the device state, usually because the emulator has not finished booting or never started; run adb wait-for-device first. "device unauthorized" on physical devices means the RSA host key was not trusted; on CI use an emulator or pre-seed adbkey. "adb: command not found" means platform-tools is not on PATH; add $ANDROID_HOME/platform-tools.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →