by Malcolm Rowe

Troubleshooting Android’s ‘adb devices’

I’ve been playing around a bit with Android development lately, and — for the second time — spent a while trying to work out why adb devices wasn’t showing me anything:

$ adb devices
List of devices attached


Thanks, adb. I’m pretty sure I’ve got a Dream plugged in there, you know. I did get it working in the end, so I thought I’d write up some of the troubleshooting steps so that I’ll have something to refer to the next time I run into this problem :-).

First off, it’s worth mentioned that if you’re on Windows, you apparently need to install some USB drivers first (and it appears that the 32-bit and 64-bit versions aren’t compatible, so you need to pick the right version too). I’m not using Windows, though, so I don’t know a whole lot about this step.

However, life’s not all rosy on Linux: the adb command scans /dev/bus/usb/ rather than /proc/bus/usb/ (as provided by usbdevfs) or /sys/bus/usb/ (ditto, sysfs). This is absolutely the right thing to do (lsusb works the same way), but it means that there’s another step (udev) between the device detection and being able to use the device.

Evidently some of the default udev rules (possibly only on some distributions; in particular, on Ubuntu) create device nodes that aren’t world-readable, meaning that the device node is created, but adb can’t read it. The easiest way to tell whether you’re having this problem is to kill the adb daemon and restart it as root:

$ adb kill-server
$ sudo adb start-server
* daemon not running. starting it now *
* daemon started successfully *
$ adb devices

(The adb daemon appears in ps as “adb fork-server server”, by the way.) I’ve also seen suggestions that you should be able to run sudo adb devices to start the server as root, but when I tried that I ended up with a daemon running as myself again.

If this is your problem, the fix is mentioned on the setup page I mentioned previously: you create a file called something like /etc/udev/rules.d/51-android.rules that contains rules telling udev to make the device node world-writable when a matching device is found.

The example rule provided in the Developer Guide matches any HTC devices, which might be a bit wide-ranging: you could presumably restrict the match to just the device’s id. (The HTC Dream and Magic share the same device id, 0bb4:0c02, or, strangely, 0bb4:0c01 when booting into HBOOT/fastboot mode.)

Finally, there’s one very important thing that I’d completely forgotten about: if the devices appears in lsusb output but adb devices still shows nothing, check that the phone is set up to allow debugging via USB (Settings⇒Applications⇒Development⇒USB debugging). If this is off, you’ll see nothing… and that was the step I’d forgotten about.

Things went much better after that: I think I might have had to restart the phone once when it was being insistent that there wasn’t a USB connection, but other than that, it’s all happy:

$ adb devices
List of devices attached
HT851N003417  device


One more thing: while looking around, I found an issue reported against the Android project that states that adb is broken against Linux kernel versions 2.6.27 and later, with identical symptoms. I’m currently using 2.6.24, so I can’t test it, but it’s worth being aware of.