How do I set up udev rules for debugging a physical android device with Android Studio?

PoisonRain picture PoisonRain · May 4, 2017 · Viewed 6.9k times · Source

In the past I've never had to set this up, but I updated Android Studio to version 2.3.1 today and got this error when clicking debug:

05/03 17:19:19: Launching app
$ adb push app-debug.apk {path on my computer}
com.android.ddmlib.AdbCommandRejectedException: insufficient permissions for device: verify udev rules.
See [http://developer.android.com/tools/device.html] for more information.
Error while Installing APK

I went to the page they specified, where they told me to make the file /etc/udev/rules.d/51-android.rules

So I did, adding this line:

SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"

For my (Huawei) Nexus 6P.

I also added the debug section to build.grade, as they specified.

However, I still get the same error. I tried substituting my own linux user group in place of plugdev, but that didn't fix the issue either. Any suggestions?

Answer

Martin Zeitler picture Martin Zeitler · Jan 17, 2019

be aware that it might report different IDs, depending on the current USB mode of the device.

therefore it's important is to enable USB debugging first ...

and then use lsusb in order to obtain the vendor & product IDs ...

Bus 001 Device 070: ID 18d1:4ee7 Google Inc.

the culprit might be the vendor ID, where 12d1 is Huawei - and 18d1 is Google.

... whatever lsusb outputs goes to udev rules:

# angler (Nexus 6P)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", MODE="0600", OWNER="yourusername"

then run:

sudo udevadm control --reload-rules