且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ADB设备命令无法正常工作

更新时间:2022-10-23 17:56:47

  

有一件事我没有尝试在编   /etc/udev/rules.d/70-android.rules。是   这可能是这个问题?

有什么特别的理由,你为什么没有这样做?要回答这个问题 - 是的! udev的规则是什么告诉Ubuntu的你的设备,并允许用户空间的工具,因此访问它。

您将无法使用亚行没有正确遵循说明

考虑到这一点不过,你不说什么版本的Ubuntu,你正在使用,但我有问题10.10 - 让我知道如果你需要我发表我的规则文件的内容

不要担心通过sudo运行ADB,你不需要它。该 MODE =0666从udev规则允许您访问设备的任何用户。


编辑:

不要忘记添加规则后,重新启动udev的:

 须藤/etc/init.d/ud​​ev重启
 

编辑#2:

由于@Jesse格里克正确地指出,如果亚行是在守护进程模式运行,您还需要重新启动这个工作:

 须藤ADB杀死服务器
 

我用sudo的位置,因为这将确保亚洲开发银行将被杀死,这是官方支持的方式来停止服务器。它会在下一次亚行用于自动重启,但这次用正确的环境。

I'm running Ubuntu 10.10 64 bit. I have ia32-libs installed along with Android Debug Bridge version 1.0.26.

My problem(s):

  1. adb devices >>> ???????????? no permissions
  2. sudo adb devices >>>> sudo: adb: command not found
  3. adb shell >>> error: insufficient permissions for device

I guess these are all related. Here's the relevant info.

$ echo $PATH
/home/me/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/android-sdk-linux_x86/tools:/opt/android-sdk-linux_x86/platform-tools

$ which adb
/opt/android-sdk-linux_x86/platform-tools/adb

$ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 
????????????    no permissions

$ sudo adb devices
sudo: adb: command not found

$ adb shell
error: insufficient permissions for device

I get the same results with a rooted Moto Droid running CM6.1 and a rooted G-Tab running a CM7-based ROM.

I have reviewed the following related posts:

I tried most (not all) of the suggestions and I have not been able to resolve my issue. The things I didn't try seemed inappropriate. I would appreciate a few more tips and I'll keep troubleshooting.

One thing I didn't try was editing /etc/udev/rules.d/70-android.rules. Is that likely to be the issue? I can't see how that would cause "sudo: adb: command not found". Maybe my problems are not all related. Anyway, at this point I think I need some input from other people because I don't believe I have a path problem or the other common problems discussed in those other posts.

EDIT: SOLVED thanks to EboMike and RivieraKid. This was actually two different problems:

  1. Item #2 above (sudo: adb: command not found) was solved by making a symlink as follows:

    $ sudo ln -s /opt/android-sdk-linux_x86/platform-tools/adb /usr/local/sbin/adb
    

    That allowed me to then do as EboMike suggested and use this solution. Doing that was required for my Moto Droid. (Running adb as sudo was not required for my Viewsonic G-Tablet, however.)

  2. My other two items were resolved by implementing the udev rule as RivieraKid suggested (from this link).

One thing I didn't try was editing /etc/udev/rules.d/70-android.rules. Is that likely to be the issue?

Any particular reason why you didn't do that? To answer the question - YES! The udev rules are what informs Ubuntu what your device is and allows user-space tools to therefore access it.

You will not be able to use adb without correctly following the instructions.

With that in mind however, you don't say what version of Ubuntu you're using but I had issues with 10.10 - let me know if you need me to post the contents of my rules file.

Don't worry about running adb via sudo, you don't need it. The MODE="0666" from the udev rule allows you to access the device as any user.


EDIT:

Don't forget to restart udev after adding the rule:

sudo /etc/init.d/udev restart

EDIT #2:

As @Jesse Glick correctly points out, if adb is already running in daemon mode, you'll also need to restart it for this to work:

sudo adb kill-server

I've used sudo here, since that will guarantee that adb will be killed , and it's the officially supported method to stop the server. It will be automatically restarted the next time adb is used, but this time with the correct environment.