adb shell 無法啟動 (insufficient permissions for device)

來源:互聯網
上載者:User

讀sdk協助文檔的時候,發現sdk已經提供了說明。使用這種方式就可以避免adb pull下來的檔案許可權為root。
詳見:docs/guide/developing/device.html

If you're developing on Ubuntu Linux, you need to add a rules file that contains a USB configuration for each type of device you want to use for development. Each device manufacturer uses a different vendor ID. The example rules files below show how to add an entry for a single vendor ID (the HTC vendor ID). In order to support more devices, you will need additional lines of the same format that provide a different value for the SYSFS{idVendor} property. For other IDs, see the table of USB Vendor IDs, below.

  1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.

    For Gusty/Hardy, edit the file to read: [註:ubuntu 7.10及以後版本]
    SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

    For Dapper, edit the file to read:  [註:ubuntu 6.06及以前版本]
    SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666"

  2. Now execute:
    chmod a+r /etc/udev/rules.d/51-android.rules

只要按照說明在/etc/udev/rules.d/目錄下建立51-android.rules,把其中的0bb4修改為相應的USB,供應商ID資訊即可。
比如My Phone是motorola,idVender是
22b8
那麼這一行就是
SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666"
不過,你可以寫多行,以使用各種裝置。比如我就寫了所有的,我的檔案如下:
#Acer      0502
SUBSYSTEM=="usb", SYSFS{idVendor}=="0502", MODE="0666"
#Dell     413c
SUBSYSTEM=="usb", SYSFS{idVendor}=="413c", MODE="0666"
#Foxconn     0489
SUBSYSTEM=="usb", SYSFS{idVendor}=="0489", MODE="0666"
#Garmin-Asus     091E
SUBSYSTEM=="usb", SYSFS{idVendor}=="091e", MODE="0666"
#HTC     0bb4
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
#Huawei     12d1
SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", MODE="0666"
#Kyocera     0482
SUBSYSTEM=="usb", SYSFS{idVendor}=="0482", MODE="0666"
#LG     1004
SUBSYSTEM=="usb", SYSFS{idVendor}=="1004", MODE="0666"
#Motorola     22b8
SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666"
#Nvidia     0955
SUBSYSTEM=="usb", SYSFS{idVendor}=="0955", MODE="0666"
#Pantech     10A9
SUBSYSTEM=="usb", SYSFS{idVendor}=="10A9", MODE="0666"
#Samsung     04e8
SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"
#Sharp     04dd
SUBSYSTEM=="usb", SYSFS{idVendor}=="04dd", MODE="0666"
#Sony Ericsson     0fce
SUBSYSTEM=="usb", SYSFS{idVendor}=="0fce", MODE="0666"
#ZTE     19D2
SUBSYSTEM=="usb", SYSFS{idVendor}=="19D2", MODE="0666"

但是我要說明的是,根據上面的這些ID,並不能包括所有的,我手上就有一台裝置的USB ID都不在上述之列。
你可以很方便的使用lsusb命令查看自己的USB ID
shily@hh-desktop:~$ lsusb
Bus 002 Device 003: ID 413c:2003 Dell Computer Corp. Keyboard
Bus 002 Device 002: ID 0461:4d22 Primax Electronics, Ltd
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 010: ID 18a1:0002
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
找到上面的id是18a1,在檔案中添加我的裝置就可以了。
SUBSYSTEM=="usb", SYSFS{idVendor}=="18a1", MODE="0666"

修改/etc/udev/rules.d/51-android.rules不需要重啟Linux機器,重新插拔一下裝置就可以了。再次運行adb devices就可以看到你的裝置已經串連
shily@hh-desktop:~$ adb devices
List of devices attached
0403502001011000    device
而在此之前,你看到的是
shily@hh-desktop:~$ adb devices
List of devices attached
????????????    no permissions

 

讀adb 命令的協助文檔,詳細的瞭解一些adb命令。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.