104

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
  • 13,991
  • 5
  • 38
  • 51
Abhishek Dwivedi
  • 4,309
  • 3
  • 12
  • 18
  • 1
    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

2 Answers2

269

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
  • 514
  • 1
  • 3
  • 20
Abhishek Dwivedi
  • 4,309
  • 3
  • 12
  • 18
  • 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
  • 6
    This s/b the accepted answer. – Roger Apr 18 '19 at 16:52
  • 4
    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
  • 15
    @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 – phyyyl Dec 17 '19 at 22:27
  • 1
    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
  • 3
    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
  • 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
152

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
  • 13,991
  • 5
  • 38
  • 51