set up device for development (???????????? no permissions)

219,548

Solution 1

What works for me is to kill and start the adb server again. On linux: sudo adb kill-server and then sudo adb start-server. Then it will detect nearly every device out of the box.

Solution 2

Nothing worked for me until I finally found the answer here: http://ptspts.blogspot.co.il/2011/10/how-to-fix-adb-no-permissions-error-on.html

I'm copying the text here in case it disappears in the future.

Create a file named /tmp/android.rules with the following contents (hex vendor numbers were taken from the vendor list page):

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1bbb", MODE="0666"

Run the following commands:

sudo cp /tmp/android.rules /etc/udev/rules.d/51-android.rules
sudo chmod 644   /etc/udev/rules.d/51-android.rules
sudo chown root. /etc/udev/rules.d/51-android.rules
sudo service udev restart
sudo killall adb

Disconnect the USB cable between the phone and the computer.

Reconnect the phone.

Run adb devices to confirm that now it has permission to access the phone.

Please note that it's possible to use , USER="$LOGINNAME" instead of , MODE="0666" in the .rules file, substituting $LOGINNAME for your login name, i.e. what id -nu prints.

In some cases it can be necessary to give the udev rules file a name that sorts close to the end, such as z51-android.rules.

Solution 3

Enter the following commands:

# cd to adb for sudo
cd `which adb | sed -e "s/adb//"`
adb kill-server
sudo ./adb start-server
./adb devices

This happens when you are not running adb server as root.  

Solution 4

Tried all above, none worked .. finally worked when I switch connected as from MTP to Camera(PTP).

Solution 5

There are a lot of bad answers posted to this question ranging from insisting on running adb as root (which should not be touted as the only or even recommended solution) to solving completely unrelated issues.

Here is the single shortest and most universal recipe for taking care of permissions for all adb and fastboot devices at once:

echo 'ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:ff420?:*", MODE="0666"' | sudo tee /etc/udev/rules.d/99-android.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --verbose --action=add --subsystem-match=usb

Or you could use slightly longer version I posted to this gist.

As for the specific thing that OP did wrong in his question - it was not reloading the udev rules after editing the .rules file.

Also OP did not tell which Android build (aka ROM) he had on his phone. The idVendor value is set in software and therefore it depends on the ROM. So the value of 04E8 he used in his original rule would have worked only for devices with Samsung stock ROMs. But this is not a problem for this udev rule - it matches all devices with adb or fastboot interfaces regardless of their VendorID.

Share:
219,548

Related videos on Youtube

Leem.fin
Author by

Leem.fin

A newbie in software development.

Updated on May 06, 2022

Comments

  • Leem.fin
    Leem.fin about 2 years

    I am using a Samsung galaxy nexus phone (Android 4.0 platform) .

    I am developing Android app on Ubuntu linux OS. I would like to run my application directly on the Samsung handset device, so I performed the following setup steps:

    1. in my project AndroidManifest.xml file, added android:debuggable="true" to the <application> element

    2. On the device, in the Settings > Security enabled Unknown sources

    3. On the device, in the Settings > Developer options enabled USB debugging

    4. On my computer, created the /etc/udev/rules.d/51-android.rules file with the following content:

      SUBSYSTEM=="usb", ATTR{idVendor}=="04E8", MODE="0666", GROUP="plugdev" 
      
    5. On my computer, run the chmod a+r /etc/udev/rules.d/51-android.rules command

    Then, on my computer I opened a terminal and executed the adb devices command, I got:

    List of devices attached 
    ????????????    no permissions
    

    Since I did not see my device but only ???????????? no permissions, I then run the following commands:

     adb kill-server
     adb start-server
     adb devices
    

    But I still got:

    List of devices attached 
    ????????????    no permissions
    

    Why? What am I missing?

    • Andro Selva
      Andro Selva over 12 years
      after exectuing adb kill-server did u get the message that * daemon not running. starting it now on port 5037 * * daemon started successfully * --- if not try it till u get this msg
    • Sergey Glotov
      Sergey Glotov over 12 years
      Try to check that your user is in plugdev group.
    • Confused
      Confused over 8 years
      Run =>sudo adb start-server (Use root access to run adb)
    • Abdulrahman Gamal
      Abdulrahman Gamal over 4 years
      finally i found the solution which worked for me in this link github.com/snowdream/51-android
    • bsautner
      bsautner over 2 years
      please see my 2022 update to this problem wayyy down below and a quick comment that some of the really old solutions here can brick a linux system.
  • Leem.fin
    Leem.fin over 12 years
    I am using my username, it does not help
  • Leem.fin
    Leem.fin over 12 years
    I use root to execute command "adb devices" under <android-SDK>/platform-tool/ , I got "No command 'adb' found", why?
  • WarrenFaith
    WarrenFaith over 12 years
    could you paste the exact command you use? I use sudo /opt/android/platform-tools/adb devices
  • Leem.fin
    Leem.fin over 12 years
    I use the same syntax command. "sudo /PATH_TO_ANDROID_SDK/platform-tolls/adb devices" It does not help
  • WarrenFaith
    WarrenFaith over 12 years
    make sure that your adb got +x -rwxrwxr-x 1 martin martin 156K 2011-11-09 15:40 adb. Try to move to the directory directly and start via "sudo ./adb devices". If you can run that without sudo, you should be able to run it with sudo... I am not sure what your issue might be...
  • Eduard Luca
    Eduard Luca over 11 years
    Note: for Ubuntu Precise the filename is 70-android.rules as per this post: esausilva.com/2010/05/13/…. Also kudos for letting us know you have to restart udev and kill all adb processes. Worked like a charm!
  • gnac
    gnac over 11 years
    You should not need to run adb as root if your udev permissions are set correctly. See grebulons answer below, or reference the android documentation: developer.android.com/tools/device.html
  • WarrenFaith
    WarrenFaith over 11 years
    Probably, but why maintaining a list if you could just use root? I have zero interest in adding a rule to it just because I test on a different device. If you just use one, no problem but with a laptop running around on conferences or with a huge amount of devices at work? No thank you.
  • Pijusn
    Pijusn over 11 years
    In case you can't manage to login using su, use sudo su. I did. And also, if you don't know how to quit the user - use exit.
  • bjunix
    bjunix over 10 years
    A similar approach is officially documented at developer.android.com/tools/device.html
  • androidevil
    androidevil over 10 years
    One important suggestion is disconect the usb cable, so you reset adb, conect the cable and it works. In my situation, while I did the procedure with the cable connected it does not work for me.
  • l.cotonea
    l.cotonea over 10 years
    Hi! Here a short script shell (tested on Linux Mint) that make the job previously described: Script shell to adb reset
  • Dmitry Koroliov
    Dmitry Koroliov almost 10 years
    though the idea is the same as in the accepted answer, this one only helped me, due to the provided example. Thanks
  • sandino
    sandino over 9 years
    This worked thanks, it has every type of device, maybe people fails in putting the rigth idVendor, for that you can put lsusb to see what the numbers is, but this almost exausthive list work great for most people
  • serjlee
    serjlee over 9 years
    This worked well but, as noted by @luciana in another answer, you might need to call sudo udevadm control --reload-rules to refresh udev rules if restarting the server isn't enough.
  • Superbiji
    Superbiji over 9 years
    You will need to add: , GROUP="plugdev" device detected successfully under ubuntu 14.04
  • wieczorek1990
    wieczorek1990 over 9 years
    You can use ATTR instead of ATTRS.
  • Asim
    Asim over 9 years
    And the commands are: adb kill-server sudo adb start-server to check: adb devices
  • Honza
    Honza about 9 years
    For Alcatel add: SUBSYSTEM=="usb", ATTRS{idVendor}=="1bbb", MODE="0666"
  • stan0
    stan0 about 9 years
    @user907860 it's actually better than the accepted answer because it explains why you should write sudo :) (which I didn't do when I saw the accepted answer)
  • stan0
    stan0 about 9 years
    btw any idea why adb should be running as root?
  • iancrowther
    iancrowther about 9 years
    sorry no, i dont remember
  • Thaddeus Albers
    Thaddeus Albers almost 9 years
    For those wondering how to do this... System settings > Storage > Upper right button: USB computer connection > Connect As Select Camera (PTP) instead of Media device (MTP)
  • hackel
    hackel over 8 years
    adb should NOT be running as root. If this is required, your system is misconfigured. Stop throwing "sudo" in front of everything, it has huge security implications.
  • Tobias
    Tobias over 8 years
    Your list says ATTRS{idVendor} but developer.android.com/tools/device.html says ATTR{idVendor} (without the 'S'). Which one is correct? (I haven't gotten either to work).
  • lastboy
    lastboy over 8 years
    I'm not sure if that was the only thing that make it work... I tried the above stuff. But w/o this post ubuntu on VBox didn't make my LG G3 authorized. Thank you Keenan
  • Jorius
    Jorius over 7 years
    man, I was looking for the solution like two hours, this works to me on ubuntu 16.04, thanks
  • Zac
    Zac over 7 years
    This should be marked as the correct answer, as sudo-ing adb shouldn't be a requirement for Linux
  • user1209216
    user1209216 about 7 years
    This is the only correct answer here. Thanks for it! Also, we can see lsusb output to make sure required vendor it is included. Most weird, only one of my devices (OnePlus One) suddenly stopped working after upgrading to Android 7.1.2 (even when run adb as root), after adding udev rules as described above, it works again.
  • grebulon
    grebulon about 7 years
    You need to create the file and copy it to the said location.
  • Alex P.
    Alex P. almost 7 years
    to apply the new udev rule without reconnecting the device just use udevadm trigger --verbose --action=add --subsystem-match=usb command.
  • Alex P.
    Alex P. almost 7 years
    instead of maintaining the list - just use a single line rule for every Android phone - stackoverflow.com/a/45006231/1778421
  • Tanasis
    Tanasis almost 7 years
    Did you maybe mean: ATTR{idVendor}=="18d1"
  • Alex P.
    Alex P. over 6 years
    why bother with "maintaining the list" when a single rule works for all? stackoverflow.com/a/45006231/1778421
  • Ciro Santilli OurBigBook.com
    Ciro Santilli OurBigBook.com over 6 years
    @AlexP. thanks I did not know about that method. Any idea why the official guide does not recomment that instead?
  • mstrange
    mstrange over 6 years
    Only missing step to see it working is adb kill-server before adb devices.
  • Hritik
    Hritik over 6 years
    I don't know why but sudo adb kill-server; sudo adb start-server didn't work but this one did.
  • Cachapa
    Cachapa over 6 years
    This doesn't seem to work anymore on Android 8.1. How did you find out what adb reports as device id?
  • Amerzilla
    Amerzilla over 6 years
    Worked for me on Android 7.1.2
  • Alex P.
    Alex P. almost 6 years
    @Cachapa, it works with all Android versions. Even the latest (at the time of me writing this) Android P Preview 4 uses the same adb interface IDs - android.googlesource.com/platform/system/core/+/…
  • Alex P.
    Alex P. almost 6 years
    Because of laziness and knowledge inertia mostly. The original Android developers used devices with the same vendor ID so they took the easiest approach they could think of. When more vendors created more devices - the developers just kept adding more IDs to the rules file.
  • m50
    m50 almost 4 years
    this should be the first thing to check. Works for me
  • Alex P.
    Alex P. almost 4 years