26

I have a HTC Desire which i would like to debug and run my Android application on. But when i in Eclipse gets the Window where i can choose between devices my HTC Desire is listed with only questionmarks (????????). What am i doing wrong?

I have tried this:

Enabled USB Debugging on my device and enabled debugging in my application Manifest.xml file.

In Terminal i have do this:

  1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.
  2. SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
  3. sudo service udev restart

What else could i try or have forgotten?

3
  • Does this happen also when you run the DDMS tool? ddms
    – Pentium10
    Commented Jun 27, 2010 at 14:03
  • Immediately after turning on USB debugging, what does running "dmesg" outputs (last lines)?
    – adamk
    Commented Jun 27, 2010 at 14:14
  • unplug and plug after generating the /etc/udev/rules.d/51-android.rules file.
    – Macarse
    Commented Jun 27, 2010 at 14:45

6 Answers 6

49

You need to run adb manually using sudo. If you just run adb without sudo (or if you let Eclipse/ADT do it for you), it won't have the permissions necessary to see your devices.

If it's already running, then sudo adb kill-server and sudo adb start-server.

3
  • 1
    Make it part of the init process - that's what I did, and it works like a charm. Create /etc/init.d/adb, copy what the other init jobs do and just call "adb start-server" and "adb kill-server" respectively, and link that in the proper rc.d directory - I created a link called /etc/rc.5d/S20adb.
    – EboMike
    Commented Oct 9, 2012 at 0:02
  • 3
    see below correct answer! I have run it without su permission using gnac answer. voted down
    – Sijav
    Commented Nov 1, 2013 at 12:51
  • 1
    @Sivaj both of the answers are correct. The problems is due to the usb device permissions. EboMike is suggesting to run adb as root so that it can access the required usb device while gnac is changing the permission of the device so that it is accessible to not root users too. Commented Aug 7, 2015 at 6:16
47

Note: EboMike's accepted answer is INCORRECT.

I know this is an old question thread, but I stumbled across it trying to resolve the same problem. However the accepted answer was incorrect. There should be no need to run the adb server as root once you have your udev rules set correctly.

Step 3 in http://developer.android.com/tools/device.html gives you the correct resolution. Specifically, add or modify /etc/udev/rules.d/51-android.rules with the following line:

SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0666", GROUP="plugdev" 

In this case 0bb4 is the vendor id for HTC. 0fff is the product id for Nexus One. Use the table at the above link, or lsusb to identify your device's vendor id & product id. eg

$ lsusb
Bus 001 Device 006: ID 18d1:4e22 Google Inc. Nexus S (debug)

18d1 is the vendor id of this particular device, and 4e22 the product id. You can leave off the "GROUP" definition if you want to enable access to this device to all users. If not, be sure to add yourself to the plugdev group if you are not in it already. After creating this file, restart or reload udev.

udevadm control --reload-rules

If you had to add yourself to a group, you will need to logout and back in again.

Kill any old adb servers with "adb kill-server", plug your device in and run "adb devices". This will restart the server and you should now see your device. Running adb as root, even just to start the adb server, is not required. It is also generally a bad idea to run things as root unless it is absolutely required.

10
  • 1
    It just doesn't work, I've even tried to reboot the system Commented Feb 2, 2013 at 9:04
  • This worked for me. I thought I already had a working 51-android.rules set, but I had inadvertently included the model ATTR as well as the vendor. I removed it. Also, I did not know the correct way to reload udev rules. I used udevadm and the adb devices command worked correctly. Commented Sep 30, 2013 at 9:28
  • 1
    YES! this one working, but mine was differenet -> SUBSYSTEM=="usb" ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="6182", ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="proprietary", ENV{ID_MEDIA_PLAYER}="1", MODE="0666", GROUP="plugdev" -> I have Sony Xperia ZR and plaese notice the plugdev and also don't forget to run sudo service udev restart for restarting whole usb services!
    – Sijav
    Commented Nov 1, 2013 at 12:54
  • yes, it does not worked,but the moment i use root, it immediately work.
    – Peter Teoh
    Commented May 15, 2014 at 16:10
  • 1
    both of the answers are correct. The problems is due to the usb device permissions. EboMike is suggesting to run adb as root so that it can access the required usb device while @gnac is changing the permission of the device so that it is accessible to not root users too. Commented Aug 7, 2015 at 6:17
3

the device-id in the adb devices commmand is actually using the serial number of the android usb devices.

So, if you get a null string from the serial number, it will display ???????????

In the adb server source code:

static size_t format_transport(atransport *t, char *buf, size_t bufsize,
                               int long_listing)
{
    const char* serial = t->serial;
    if (!serial || !serial[0])
        serial = "????????????";

So, it could be that your adb server is not running at root privilege, or your usb devices does't not allow adb server to read. A simple check would be using lsusb -v | grep iSerial to see if you can get the iSerial field of your android device.

Also, there're chances the iSerial string is not prepared well in the device. I've seen a lot of engineering product doesn't have the iSerial at all, or all of the devices are displaying the same device id.

Some times, the driver will read a section of data in the flash which is programmed uniquely from device to device to make it iSerial/device id.

2

I've managed to get my "bricked" Nexus S working again by doing what is said here. One small addition was necessary, though.

When you do an lsusb and the USB subsystem tells you which Android device is attached, mine was giving me back:

$ lsusb
Bus 001 Device 006: ID 18d1:d001 Google Inc.

Note the d001 and not any of the known states, i.e. 4e20, 4e21 or 4e22. So what I did is to add another row in 51-android.rules specifically with this unknown state and mark it as "recovery/debug".

Disconnect and reconnect Android. Check lsusb again to make sure it is at least seen. And... That gave me this

$ adb devices
List of devices attached
34353601BB2000EC    recovery

instead of this

$ adb devices -l
List of devices attached 
????????????           no permissions usb:1-3

After that, I simply followed the howto for restoring the factory images. Hope it helps.

1

This is because you haven't given your adb the permission to access to your hardware. You have two solutions:

temporary -> kill all existing adb processes and restart with super user

ps -ef | grep adb | awk '{print $2}' | xargs kill

sudo adb server-restart

or

sudo <your android SDK path>/platform-tools/adb server-restart

permanent -> add your devices to udev list Add following line to your /etc/udev/rules.d/51-android.rules as root with correct idVendor using this list.

SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

followed by following command:

chmod a+r /etc/udev/rules.d/51-android.rules

If adb doesn't work do the following:

sudo ln -s <your android SDK path>/platform-tools/adb /usr/local/sbin/adb
0

Make sure you installed sudo apt-get install android-tools-adb Now check sudo adb It will show help of adb

Now please kill/start adb use following commands -

sudo adb kill-server sudo adb start-server

Lastly, sudo adb devices

Hopefully this will work !!!

Not the answer you're looking for? Browse other questions tagged or ask your own question.