Skip to content

Instantly share code, notes, and snippets.

@florianroulet
Last active December 20, 2018 17:17
Show Gist options
  • Save florianroulet/888f108604ca9f4667f1f4f0fce0add6 to your computer and use it in GitHub Desktop.
Save florianroulet/888f108604ca9f4667f1f4f0fce0add6 to your computer and use it in GitHub Desktop.
set correct rules for android device / adb

source : http://www.janosgyerik.com/adding-udev-rules-for-usb-debugging-android-devices/

symptoms

$ adb devices

List of devices attached

???????????? no permissions

resolution

identify device

lsusb

Bus 001 Device 003: ID 0cf3:e300 Atheros Communications, Inc.

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

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

check permissions

ls -l /dev/bus/usb/001/002

crw-rw-r-T 1 root root 189, 8 Nov 10 18:34 /dev/bus/usb/001/002

The problem is clear: the file is owned by user root and group root, which I am neither. The elegant solution is to add a udev rule so that the device will belong to a reasonable group, like plugdev, of which I’m a member.

solution

Create a udev rules file, let’s say: /etc/udev/rules.d/51-android.rules

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", MODE="0660",

GROUP="plugdev", SYMLINK+="android%n"

Here, idVendor and idProduct come from the output of lsusb: 18d1:4ee7. Do similarly for your own device. The rule specifies that a matching USB device should be created with permissions 0660, with group plugdev, and a symlink conveniently pointing to it.

Now that everything is ready, simply plug the device out and back in to confirm the result:

$ lsusb | grep Google

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

$ ls -l /dev/bus/usb/001/002

crw-rw---- 1 root plugdev 189, 1 déc. 20 18:13 /dev/bus/usb/001/002

$ adb devices

List of devices attached

000003a76fdac462 device

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment