linux adb 权限不够,关于adb命令没有权限访问手机设备的有关问题

关于adb命令没有权限访问手机设备的问题

关于adb命令没有权限访问手机设备的问题

在使用Ubuntu的朋友应该碰到过在执行adb相关命令的时候会提示如下的错误:

liubzh@liubzh-PC:/$ adb shell

error: insufficient permissions for device

liubzh@liubzh-PC:/$ adb devices

List of devices attached

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

在网络上搜索解决方案,发现最多的是如下的建议:

更改用户和组为root,此方法摘自此处。

转到adb所在的目录

shily@hh-desktop:~$cd ~/sdk/android-sdk_eng.sdk_linux-x86/tools

shily@hh-desktop:~/sdk/android-sdk_eng.sdk_linux-x86/tools$ls -ladb

-rwxr-xr-x 1 shily shily 341694 2010-05-11 05:46 adb

shily@hh-desktop:~/sdk/android-sdk_eng.sdk_linux-x86/tools$sudo chown root:root adb

[sudo] password for shily:

shily@hh-desktop:~/sdk/android-sdk_eng.sdk_linux-x86/tools$ls -ladb

-rwxr-xr-x 1root root 341694 2010-05-11 05:46 adb

shily@hh-desktop:~/sdk/android-sdk_eng.sdk_linux-x86/tools$sudo chmod u+s adb

shily@hh-desktop:~/sdk/android-sdk_eng.sdk_linux-x86/tools$ls -ladb

-rwsr-xr-x 1 root root 341694 2010-05-11 05:46 adb

shily@hh-desktop:~/sdk/android-sdk_eng.sdk_linux-x86/tools$

或者直接以root启动adb-server,此方法摘自此处:

So you probably need to do “adb start-server” as root first:

ubuntu$ sudo ./out/host/linux-x86/bin/adb kill-server

ubuntu$ sudo ./out/host/linux-x86/bin/adb start-server

* daemon not running. starting it now *

* daemon started successfully *

ubuntu$ ./out/host/linux-x86/bin/adb shell

但是,这样还是很麻烦,我们应该通过Android官方网站的方式来解决这个问题:

Set up your system to detect your device.

If you're developing on Windows, you need to install a USB driver for adb. For aninstallation guide and links to OEM drivers, see theOEM USBDrivers document.

If you're developing on Mac OS X, it just works. Skip this step.

If you're developing on Ubuntu Linux, you need to add audev rules file that contains a USB configuration for each type of deviceyou want to use for development. In the rules file, each device manufactureris identified by a unique vendor ID,

as specified by theATTR{idVendor} property. For a list of vendor IDs, seeUSB Vendor IDs, below. To set up device detection onUbuntu Linux:

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

Use this format to add each vendor to the file:

SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

In this example, the vendor ID is for HTC. The MODEassignment specifies read/write permissions, andGROUP defineswhich Unix group owns the device node.

Note: The rule syntaxmay vary slightly depending on your environment. Consult theudevdocumentation for your system as needed. For an overview of rule syntax, seethis guide towriting

udevrules.

Now execute:

chmod a+r /etc/udev/rules.d/51-android.rules

详见http://developer.android.com/tools/device.html。

我们只需要这样在udev中订制化我们自己的usb设备即可。

如下命令我们可以查看vendor

id和product id:

liubzh@liubzh-PC:~$ lsusb

Bus 002 Device 009: ID 24e3:7112

Bus 002 Device 003: ID 064e:c108 Suyin Corp.

Bus 005 Device 002: ID 192f:0916 Avago Technologies, Pte.

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

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

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

另见http://source.android.com/source/initializing.html#configuring-usb-access:

Configuring USB Access

Under GNU/linux systems (and specifically under Ubuntu systems),regular users can't directly access USB devices by default. Thesystem needs to be configured to allow such access.

The recommended approach is to create a file/etc/udev/rules.d/51-android.rules (as the root user) and to copythe following lines in it. must be replaced by theactual username of the user who

is authorized to access the phonesover USB.

如:

SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", ATTR{idProduct}=="7112", MODE="0600", OWNER="liubzh"

重新插拔USB设备,adb命令将会正常被执行。

转载请著名出处。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值