Explain Codes LogoExplain Codes Logo

Adb devices => no permissions (user in plugdev group; are your udev rules wrong?)

career
interview-preparation
best-practices
tools
Anton ShumikhinbyAnton Shumikhin·Sep 11, 2024
TLDR

Quick fix coming at you at warp speed! Run the following command to overcome the adb devices no permission obstacle:

# Who's the boss? You're the boss! sudo adb kill-server && sudo adb start-server

Still no joy? Let's compose a udev rule specifically for your Android device:

# Here comes the secret sauce! echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="VENDOR_ID", MODE="0666", GROUP="plugdev"' | sudo tee /etc/udev/rules.d/51-android-usb.rules

Remember to replace VENDOR_ID with your device's unique vendor ID. Now, let's make udev aware of the changes:

sudo udevadm control --reload-rules && sudo udevadm trigger

Unplug and then plug your device back in, and run adb devices. Voilà, the pesky permission issue should be gone!

But what if the fast answer doesn't work?

No problem, dear coder, we've got more tricks up our sleeve! Here’s how you ensure device detection with the lsusb command:

lsusb # If lsusb was a dating app, this would be swiping right!

From the output, you'll extract your device’s vendor ID and product ID—the secret codes we'll be using to charm our way past permission issues!

Query the command, get the answers

Uncover your Android device from the lsusb command. Here’s how to identify your unique device ID:

# I see you! Bus 002 Device 003: ID 18d1:4ee7 Google Inc.

In this output, 18d1 is the elusive VENDOR_ID.

Create, apply, and conquer!

Forge a udev rule that'll unlock adb access to your Android device:

# Shhh, we're hacking (not really) echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"' | sudo tee /etc/udev/rules.d/51-android.rules

Use your magic incantation to have udev take your new rule to heart:

sudo udevadm control --reload-rules && sudo udevadm trigger

Confirm device detection

Get adb’s blessing on the device's recognition:

adb devices # Don't let the machines win!

A returned device list means you've escaped the no permission error!

Persist? Here's how you resist

File Transfer/MTP mode

Switch your device to File Transfer or MTP mode. ADB gets grouchy with “Charging only”.

Test different cable

Only the best (quality) cables for adb!

adb and Genius Bar

Ensure your adb version is the latest. Who knows, the Genius Bar might start accepting adb!

Resurrections

adb reboot

Try restarting the adb service.

# Rest is important for everyone, even lines of code! adb kill-server && adb start-server

Check connections

Unplug and replug your device. It's the equivalent of "switching it off and on".

System reboot

Give your whole system a break and a reboot. You'd be surprised at what a nap can fix sometimes.