日期:2014-05-16  浏览次数:20694 次

关于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 rule