Ubuntu: Android device debug

27,968

Solution 1

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.

Solution 2

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.

Solution 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.

Solution 4

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.

Solution 5

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
Share:
27,968

Related videos on Youtube

Poku
Author by

Poku

Updated on July 09, 2022

Comments

  • Poku
    Poku almost 2 years

    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?

    • Pentium10
      Pentium10 almost 14 years
      Does this happen also when you run the DDMS tool? ddms
    • adamk
      adamk almost 14 years
      Immediately after turning on USB debugging, what does running "dmesg" outputs (last lines)?
    • Macarse
      Macarse almost 14 years
      unplug and plug after generating the /etc/udev/rules.d/51-android.rules file.
  • EboMike
    EboMike over 11 years
    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.
  • Kirill Kulakov
    Kirill Kulakov over 11 years
    It just doesn't work, I've even tried to reboot the system
  • Nick Coleman
    Nick Coleman over 10 years
    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.
  • Sijav
    Sijav over 10 years
    see below correct answer! I have run it without su permission using gnac answer. voted down
  • Sijav
    Sijav over 10 years
    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!
  • Peter Teoh
    Peter Teoh about 10 years
    yes, it does not worked,but the moment i use root, it immediately work.
  • tomasb
    tomasb about 10 years
    this wasnt working for me too until i reconnected the device and also sudo service udev restart with adb restart, now OK thanks
  • 0x0me
    0x0me over 9 years
    Worked after enabling the developer mode (usb debugging) on my phone. This is a sort of weird since Android 4.2 .
  • 4aRk Kn1gh7
    4aRk Kn1gh7 almost 9 years
    @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.
  • 4aRk Kn1gh7
    4aRk Kn1gh7 almost 9 years
    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.
  • arielCo
    arielCo almost 9 years
    @4aRkKn1gh7, both sudo ./adb sideload ....zip and sudo ./adb devices failed with "no permissions". I had to give permissions to plugdev even when the flags were crw-rw-----. Any idea why?
  • Noundla Sandeep
    Noundla Sandeep about 8 years
    As mentioned in this, I followed step3 from the given link and it worked perfectly. Thanks for pointing out. :)
  • Hritik
    Hritik about 4 years
    Archlinux users, pacman -S android-udev and reconnect your device.