163

I am getting following error log if I connect my android phone with Android Oreo OS to Linux PC

$ adb devices
List of devices attached
xxxxxxxx    no permissions (user in plugdev group; are your udev rules wrong?);
see [http://developer.android.com/tools/device.html]

I tried with the link provided by the error message but still getting same error.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
Abhishek Dwivedi
  • 6,557
  • 3
  • 15
  • 20
  • 3
    I had the same issue and solved following the steps from the link. `adb` was installed manually and added to my path (fresh install of Linux) but I kept getting the error. I proceeded to remove it and install it again via `apt install adb` (Ubuntu-based distro). After that I've doubled checked that my user was, in fact, part of the `plugdev` group, rebooted the machine and plugged in the device again. Got the permission dialog displayed and all worked as expected without any hacking. :) – Mokkun Jan 07 '20 at 04:52
  • Just run it with sudo https://stackoverflow.com/a/15043526/3957754 – JRichardsz May 16 '22 at 01:07
  • just do it sudo apt-get install android-sdk-platform-tools-common – Md. Ruhul Amin Jun 06 '22 at 10:00
  • 2
    `sudo apt-get install -y android-sdk-platform-tools-common && sudo cp /lib/udev/rules.d/51-android.rules /etc/udev/rules.d/` – ealfonso Nov 20 '22 at 02:06
  • @Mokkun comment worked like a charm on my Rpi Zero. – kyrlon Aug 19 '23 at 04:04

2 Answers2

416

Check device vendor id and product id:

$ lsusb
Bus 001 Device 002: ID 8087:8000 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 078: ID 138a:0011 Validity Sensors, Inc. VFS5011 Fingerprint Reader
Bus 002 Device 003: ID 8087:07dc Intel Corp. 
Bus 002 Device 002: ID 5986:0652 Acer, Inc 
Bus 002 Device 081: ID 22b8:2e81 Motorola PCS 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Here my android device is Motorola PCS. So my vid=22b8 and pid=2e81.

Now create a udev rule:

$ sudo vi /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="2e81", MODE="0666", GROUP="plugdev"

Now the device is good to be detected once udev rule is reloaded. So, let's do it:

$ sudo udevadm control --reload-rules

After this, again check if your device is detected by adb:

$ adb devices
List of devices attached
ZF6222Q9D9  device

So, you are done.

If it still doesn't work, unplug/replug the device.

If it still doesn't work, restart your OS.

OoDeLally
  • 552
  • 1
  • 5
  • 21
Abhishek Dwivedi
  • 6,557
  • 3
  • 15
  • 20
  • 1
    This answer is a more durable solution as the file transfer (MTP) workaround doesn't persist as well across device reboots, etc. – JPvRiel Apr 14 '19 at 18:22
  • 7
    This s/b the accepted answer. – Roger Apr 18 '19 at 16:52
  • 5
    Don't laugh, but I actually had to reboot Mint in actually for this to work, seemed that the `udevadm` command was being ineffective. – Henrique de Sousa Jul 03 '19 at 20:49
  • 31
    @HenriquedeSousa Had to unplug and plug back, which triggered "allow this computer ..." dialog on the Android device. – Majkeee Aug 05 '19 at 07:49
  • 2
    @HenriquedeSousa I had to do the same on mint. – Wiktor Wardzichowski Aug 30 '19 at 09:27
  • 1
    does not work for me – 2xMax Sep 08 '19 at 17:14
  • 1
    Worked for me. Before "flutter devices" gave me "Android Null (API null)". And now "Android 10 (API 29)". Thanks – 1cedsoda Dec 17 '19 at 22:27
  • 2
    How come we name the file: `51-android.rules`? I.e. why the 51? – v_johan May 03 '20 at 14:37
  • It works! Thanks. Fedora doesn't have plugdev group, so ignore GROUP="plugdev" if you use Fedora. – Manuel Lopera May 19 '20 at 19:44
  • Just an update - running `sudo udevadm trigger`, followed by re-plugging the device worked for me (didn't require a reboot) on Linux Mint. – roshnet Jun 24 '20 at 10:31
  • 4
    Going through the USB / tethering settings on the device (pull down global notifications menu) and switching to File Transfer and disabling tethering worked for me. – fatal_error Aug 07 '20 at 15:47
  • 1
    On a Xaomi Redmi Note 8, Ubuntu 20.04.1 LTS, I had to add it to the 51-android.rules file (SUBSYSTEM=="usb", ATTR{idVendor}=="ff08", MODE="0666", GROUP="plugdev") and then choose file transfer mode in the popup dialog when I plugged in the device. – James Moore Aug 20 '20 at 17:28
  • What would I do without stackoverflow ... – Boern Nov 17 '20 at 20:25
  • 1
    Used a combination of this answer as well as this one https://stackoverflow.com/a/12664045/2356570. – capt.swag Dec 17 '20 at 18:20
  • Everything worked for me after rebooting the system. But in general, everything is correct! – gc986 Jan 13 '21 at 10:33
  • I think switching between recovery mode and fastboot changes the idProduct. So, you can omit ATTR{idProduct} part in the rule. Cheers – MRazian Feb 09 '21 at 08:27
  • If you are on Ubuntu, you can install the `android-sdk-platform-tools-common` package, which contains a community-maintained default set of udev rules for Android devices: https://developer.android.com/studio/run/device#setting-up – Benedikt Köppel Jul 11 '21 at 19:10
  • I ended up adding 2 lines `SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d00d", MODE="0666", GROUP="plugdev"` and `SUBSYSTEM=="usb", ATTR{idVendor}=="2717", ATTR{idProduct}=="ff48", MODE="0666", GROUP="plugdev"` – Mohammed Sufian Jul 23 '21 at 13:40
217

I don't know the reason behind this issue. But a temporary fix would be to set the phone to File Transfer mode or MTP mode.

The problem with this fix is that you'll need to set the mode from charging mode to File transfer mode or MTP mode every time the cable is connected.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
  • 3
    for some reason, this work. Change to File Tranfer mode and device asked for permission. Then adb kill-server adb start server and now my device is recognized. tks – cesarsicas Dec 28 '18 at 13:27
  • 10
    The reason this works is because it changes the `pid` in `lsusb` to one which is in your `udev` rules – Pieter Jun 22 '19 at 20:20
  • 1
    android 10 it worked !!!thanks – sudhakar selva Nov 09 '20 at 08:46
  • 1
    This works if you want just `adb`, but for `fastboot` to also work, you need to use the other answer. – Jan Pokorný Apr 14 '21 at 18:19
  • revoking usb debugging authorizations also works (permission dialog pops up) – starenka Jan 20 '22 at 09:49
  • 1
    Same issue happened with me! enabling the file transfer mode solved all sorts of trouble, Thanks! – Code Cooker Jun 20 '22 at 07:08
  • @Pieter, I don't think so. This answer worked for me whereas the answer to edit udev rules had not (well, I had not restarted, only replugged, but I'm against mindless reboots). I guess not all usb connection modes support adb connection. – Alex Martian Feb 02 '23 at 10:50