Linux adb devices 命令不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5510284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
adb devices command not working
提问by MountainX
I'm running Ubuntu 10.10 64 bit. I have ia32-libs installed along with Android Debug Bridge version 1.0.26.
我正在运行 Ubuntu 10.10 64 位。我安装了 ia32-libs 和 Android Debug Bridge 1.0.26 版。
My problem(s):
我的问题:
adb devices
>>> ???????????? no permissionssudo adb devices
>>>> sudo: adb: command not foundadb shell
>>> error: insufficient permissions for device
adb devices
>>> ???????????? 没有权限sudo adb devices
>>>> sudo: adb: 命令未找到adb shell
>>> 错误:设备权限不足
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.
我使用运行 CM6.1 的有根 Moto Droid 和运行基于 CM7 的 ROM 的根 G-Tab 得到相同的结果。
I have reviewed the following related posts:
我已经查看了以下相关帖子:
- http://forum.xda-developers.com/archive/index.php/t-522827.html
- http://ubuntuforums.org/archive/index.php/t-1164359.html
- adb command not found in linux environment
- http://forum.xda-developers.com/archive/index.php/t-522827.html
- http://ubuntuforums.org/archive/index.php/t-1164359.html
- 在 linux 环境中找不到 adb 命令
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.
我没有尝试的一件事是编辑 /etc/udev/rules.d/70-android.rules。这可能是问题吗?我看不出这将如何导致“sudo: adb: command not found”。也许我的问题并不都是相关的。无论如何,在这一点上,我认为我需要其他人的一些意见,因为我不认为我有路径问题或其他帖子中讨论的其他常见问题。
EDIT: SOLVEDthanks to EboMike and RivieraKid. This was actually two different problems:
编辑:感谢 EboMike 和 RivieraKid 解决。这实际上是两个不同的问题:
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 notrequired for my Viewsonic G-Tablet, however.)
My other two items were resolved by implementing the udev rule as RivieraKid suggested (from this link).
采纳答案by RivieraKid
One thing I didn't try was editing /etc/udev/rules.d/70-android.rules. Is that likely to be the issue?
我没有尝试的一件事是编辑 /etc/udev/rules.d/70-android.rules。这可能是问题吗?
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.
你没有这样做有什么特别的原因吗?回答这个问题 - 是的!udev 规则通知 Ubuntu 你的设备是什么,并允许用户空间工具访问它。
You will not be able to use adb without correctly following the instructions.
如果不正确遵循说明,您将无法使用 adb 。
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.
然而,考虑到这一点,您没有说明您使用的是哪个版本的 Ubuntu,但我在 10.10 上遇到了问题 - 如果您需要我发布规则文件的内容,请告诉我。
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.
不要担心通过 sudo 运行 adb,你不需要它。在MODE="0666"
从udev规则允许您使用该设备的任何用户。
EDIT:
编辑:
Don't forget to reload the rules:
不要忘记重新加载规则:
sudo udevadm control --reload-rules
EDIT #2:
编辑#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:
正如@Jesse Glick 正确指出的那样,如果 adb 已经在守护程序模式下运行,您还需要重新启动它才能正常工作:
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.
我在这里使用了 sudo ,因为这将保证 adb 将被杀死,并且它是官方支持的停止服务器的方法。下次使用 adb 时它会自动重新启动,但这次使用正确的环境。
回答by RzR
I fixed this issue on my debian GNU/Linux system by overiding system rules that way :
我通过以这种方式覆盖系统规则在我的 debian GNU/Linux 系统上解决了这个问题:
mv /etc/udev/rules.d/51-android.rules /etc/udev/rules.d/99-android.rules
I used contents from files linked at : http://rootzwiki.com/topic/258-udev-rules-for-any-device-no-more-starting-adb-with-sudo/
我使用了链接文件中的内容:http: //rootzwiki.com/topic/258-udev-rules-for-any-device-no-more-starting-adb-with-sudo/
回答by larkee
On my Gentoo/Funtoo linux system I am having similar problems:
在我的 Gentoo/Funtoo linux 系统上,我遇到了类似的问题:
I gotting always not the correct device description and insufficient permissions:
我总是不正确的设备描述和权限不足:
# sudo ./adb devices
List of devices attached
???????????? no permissions
# ./adb usb
error: insufficient permissions for device
For me helps the howtofrom Google. In my case I needed to add the udev rule:
对我来说帮助Google的howto。就我而言,我需要添加 udev 规则:
# cat /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
and setting up the filesystem rights
并设置文件系统权限
# chmod a+r /etc/udev/rules.d/51-android.rules
After replugging my smartphone the access to the phone was successful, it also appears now in Eclipse' Android Device Chooser:
重新插入我的智能手机后,手机访问成功,它现在也出现在 Eclipse 的 Android 设备选择器中:
# sudo ./adb devices
List of devices attached
3XXXXXXXXXXXXXC device
# sudo ./adb usb
restarting in USB mode
You also have to check the membership of your user to the plugdev-group.
您还必须检查您的用户对plugdev-group的成员资格。
回答by sebastianwagner
Please note that IDEs like IntelliJ IDEAtend to start their own adb-server.
请注意,像IntelliJ IDEA这样的 IDE倾向于启动自己的 adb-server。
Even manually killing the server and running an new instance with sudo won't help here until you make your IDE kill the server itself.
即使手动终止服务器并使用 sudo 运行新实例也无济于事,除非您让 IDE 自行终止服务器。
回答by anon
Every answer I've read indicates the SUBSYSTEM=="usb"
. However, my (perhaps ancient) udev needed this to be changed to DRIVER=="usb"
. At last I can run the adb server as a non-root user... yay.
我读过的每个答案都表明SUBSYSTEM=="usb"
. 但是,我的(可能是古老的)udev 需要将其更改为DRIVER=="usb"
. 最后,我可以以非 root 用户身份运行 adb 服务器......是的。
It can be instructive to look at the output of udevmonitor --env, followed by the output of
查看 udevmonitor --env 的输出,然后是
udevinfo -a -p <DEVICE_PATH_AS_REPORTED_BY-udevmonitor>
回答by cinderman
HTC One m7 running fresh Cyanogenmod 11.
HTC One m7 运行新鲜的 Cyanogenmod 11。
Phone is connected USB and tethering my data connection.
手机已连接 USB 并绑定我的数据连接。
Then I get this surprise:
然后我得到了这个惊喜:
cinder@ultrabook:~/temp/htc_m7/2015-11-11$ adb shell
error: insufficient permissions for device
cinder@ultrabook:~/temp/htc_m7/2015-11-11$ adb devices
List of devices attached
???????????? no permissions
SOLUTION: Turn tethering OFF on phone.
解决方案:在手机上关闭网络共享。
cinder@ultrabook:~/temp/htc_m7/2015-11-11$ adb devices
List of devices attached
HT36AW908858 device
回答by Andrii Krokhin
I just got the same situation, Factory data reset worked well for me.
我遇到了同样的情况,恢复出厂设置对我来说效果很好。
回答by keredson
restarting the adb server as root worked for me. see:
以 root 身份重新启动 adb 服务器对我有用。看:
derek@zoe:~/Downloads$ adb sideload angler-ota-mtc20f-5a1e93e9.zip
loading: 'angler-ota-mtc20f-5a1e93e9.zip'
error: insufficient permissions for device
derek@zoe:~/Downloads$ adb devices
List of devices attached
XXXXXXXXXXXXXXXX no permissions
derek@zoe:~/Downloads$ adb kill-server
derek@zoe:~/Downloads$ sudo adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
derek@zoe:~/Downloads$ adb devices
List of devices attached
XXXXXXXXXXXXXXXX sideload