Adb device unauthorized problem


Sometimes when you want to use adb for debug purpose, you may get a device not authorized error.

You should first check output of the following command:

$ adb devices -l
List of devices attached 
????????????           no permissions usb:1-1

If you see similar output which basically says that you have no permissions to use this usb device, there are two possible solutions.

Most people try to solve this problem with running adb as root user or make adb binary setuid-root. But it is not suggested to being root to run adb.

When an usb device plugged in, udev system takes required actions if there is a matching rule for that device. If there is no special rule exist, device permissions set by only root user access which you can check on /dev/bus/usb/<bus-no>/<device-no>

If you want to use adb without being root, you need to add correct udev rules for your android device. To do this, first of all you have to learn Vendor ID and Product ID of your device from lsusb output:

$ lsusb
Bus 001 Device 002: ID 0fce:51bb Sony Ericsson Mobile Communications AB

In above example, vendor id is 0fce and product id is 51bb. After that you must create a new udev rules file with a name like /etc/udev/rules.d/99-android.rules and add following line:

SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", ATTR{idProduct}=="51bb" \
MODE="0666", GROUP="plugdev"

Above line basically tells about udev to when it detects an usb device with specific vendor and product id, group ownership of the device must be set to plugdev group.

Plugdev group automatically created by the Linux distributions and probably you already in this group. If not, you will need to add yourself to plugdev group too.

After all the configuration completed, you need to reload udev rules and restart the service:

$ sudo udevadm control --reload-rules
$ sudo service udev restart

If your usb cable already plugged, remove and plug it again. Now you can see your device on adb output:

$ adb devices -l
List of devices attached 
YT9111K3H1             unauthorized usb:1-1

Device seen but it says still unauthorized, your android system must be show a popup window to give authorization to your Linux system. When you accept it, you will start to use adb as a normal user:

$ adb devices -l
List of devices attached 
YT9111K3H1     device usb:1-1 product:D5803 model:D5803 device:D5803