LinuxCommandLibrary

adb-devices

List connected Android devices

TLDR

List devices

$ adb devices
copy

List devices and their system info
$ adb devices -l
copy

SYNOPSIS

adb [global_options] devices [-l]

Explanation:
adb: The main Android Debug Bridge executable.
devices: The specific subcommand to list connected devices.
global_options: Optional flags that apply to all adb commands (e.g., specifying a different ADB server host or port).
-l: An optional parameter for a 'long format' listing.

PARAMETERS

-l
    Provides a 'long format' listing, which includes additional details for each connected device such as the product name, model, and device identifier. This can be particularly useful when distinguishing between multiple similar devices.

[global_options]
    While not specific to the 'devices' subcommand, adb supports various global options that can precede any command. Examples include -H to connect to a specific ADB server host, or -P to connect to a specific port. These options allow targeting different ADB server instances if needed.

DESCRIPTION

The adb devices command is a core utility within the Android Debug Bridge (ADB) framework. Its primary purpose is to display a list of all Android devices (physical phones, tablets, or emulators) currently connected to the host computer. These connections can be established via USB or, if configured, over a network (Wi-Fi).

Upon execution, if the ADB server is not already running, adb devices will automatically start it. The server then scans for and identifies connected devices. For each detected device, the command typically outputs a unique serial number and its current connection state (e.g., "device", "offline", or "unauthorized"). This command is essential for developers and power users as it serves as the initial verification step to ensure a device is properly recognized and ready for further ADB operations, such as installing applications, transferring files, or accessing the device's shell.

CAVEATS

USB Debugging Disabled: Devices must have USB debugging enabled in their Developer Options for ADB to recognize them.
Unauthorized Device: A device may appear as 'unauthorized' if you haven't accepted the RSA key fingerprint prompt on the device's screen upon its first connection.
Driver Issues: On Windows, missing or outdated USB drivers are a common cause of devices not being detected.
ADB Server Conflict: Sometimes the ADB server can crash or conflict with other instances. Running adb kill-server followed by adb devices often resolves such issues.
Firewall/Network: For ADB over Wi-Fi, firewall settings on either the host or device can block the connection.
Faulty Cable/Port: A damaged USB cable or a malfunctioning USB port can prevent proper device detection.

DEVICE STATES IN OUTPUT

The output of adb devices typically shows the following states for a connected device:
device: Indicates that the device is successfully connected to the ADB server and is ready to accept commands.
offline: The device is connected, but it is not responding to ADB commands. This can happen during a device reboot, or if there's a problem with the connection that needs troubleshooting.
unauthorized: The device is physically connected, but you have not yet granted permission for your computer to debug it. A prompt usually appears on the device's screen asking for authorization; you must accept this prompt to proceed.

TROUBLESHOOTING COMMON ISSUES

If your device is not listed by adb devices:
1. Double-check your USB cable and try a different USB port.
2. Ensure that 'USB debugging' is enabled in the 'Developer Options' on your Android device.
3. Look for an 'Allow USB debugging?' authorization prompt on your device's screen and accept it.
4. Restart the ADB server by running adb kill-server followed by adb devices.
5. On Windows, verify that you have the correct Android USB drivers installed and updated.

HISTORY

The adb tool, including the devices subcommand, has been an integral part of the Android SDK (Software Development Kit) since the early days of the Android operating system. It was designed from the outset as a primary interface for developers and power users to interact with Android devices for debugging, application development, and system administration tasks. The adb devices command, in particular, has remained a foundational utility, serving as the essential first step to confirm connectivity and availability of devices. Its consistent functionality and critical role underscore its enduring importance in the Android ecosystem's evolution.

SEE ALSO

adb(1), fastboot(1), lsusb(8), adb logcat, adb install

Copied to clipboard