Ubuntu 下 adb 报错:
1 2 3 |
~/android/sdk/platform-tools$ ./adb devices List of devices attached 0badbeef no permissions (user in plugdev group; are your udev rules wrong?); see [http://developer.android.com/tools/device.html] |
解决方案:
Step 1: lsusb 找到手机的 USB 地址
1 2 3 4 5 6 7 |
~/android/sdk/platform-tools$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 005: ID 8087:0a2b Intel Corp. Bus 001 Device 004: ID 0bda:5650 Realtek Semiconductor Corp. Bus 001 Device 003: ID 12d1:15c0 Huawei Technologies Co., Ltd. Bus 001 Device 007: ID 18d1:4ee7 Google Inc. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub |
在上面的输出中找下,如果无法辨别,那么拔掉手机再看下,与上次的输出相比较,哪个不见了就是哪个,把 ID 后面冒号后的部分记住。
Step 2: sudo gedit /etc/udev/rules.d/51-android.rules
1 2 |
~/android/sdk/platform-tools$ sudo gedit /etc/udev/rules.d/51-android.rules [sudo] password for user: |
把以下文本粘贴到编辑器里,注意把 b055 改作上面让你记住的那个数值:
1 |
ATTR{idProduct}=="b055", SYMLINK+="android_adb", MODE="0660", GROUP="plugdev", TAG+="uaccess", SYMLINK+="android" |
Step 3: 执行以下命令
1 2 3 4 |
~/android/sdk/platform-tools$ sudo usermod -a -G plugdev $(id -u -n) ~/android/sdk/platform-tools$ sudo udevadm control --reload-rules ~/android/sdk/platform-tools$ sudo service udev restart ~/android/sdk/platform-tools$ sudo udevadm trigger |
Step 4: 重启 adb
1 2 3 4 5 |
~/android/sdk/platform-tools$ ./adb kill-server ~/android/sdk/platform-tools$ ./adb start-server ~/android/sdk/platform-tools$ ./adb devices List of devices attached 0badbeef unauthorized |