ADB Android 设备未经授权
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23081263/
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 Android Device Unauthorized
提问by Quak
Since I reinstalled Eclipse (simply deleted and downloaded it again) I can't debug my applications on Samsung Galaxy i9001 (with CyanogenMod - Android 4.4.2). It worked fine before reinstallation.
由于我重新安装了 Eclipse(只是删除并再次下载),我无法在 Samsung Galaxy i9001(使用 CyanogenMod - Android 4.4.2)上调试我的应用程序。在重新安装之前它工作正常。
Unplug/plug, Uncheck/check "Debug Enabled", adb kill-server/adb start-server, restart phone/computer doesn't work for me. On the device authorize dialog never appears (but I remember that dialog appeared before reinstallation). I have no idea how to force this authorize dialog to display. There is no abd_key.pub file in .android directory. When i try read cpu info DDMS says:
拔下/插入,取消选中/选中“启用调试”,adb kill-server/adb start-server,重新启动手机/计算机对我不起作用。在设备上从未出现授权对话框(但我记得在重新安装之前出现了该对话框)。我不知道如何强制显示此授权对话框。.android 目录中没有 abd_key.pub 文件。当我尝试读取 CPU 信息时,DDMS 说:
[2014-04-15 12:47:06 - DDMS] device unauthorized. Please check the confirmation dialog on your device.
Any ideas? Is it possible to generate keys manually without confirmation dialog?
有任何想法吗?是否可以在没有确认对话框的情况下手动生成密钥?
USB Connection
USB连接
Wireless Connection
无线连接
回答by Martin
It's likely that the device is no longer authorized on ADBfor whatever reason.
无论出于何种原因,该设备可能不再在ADB 上获得授权。
1. Check if authorized:
1.检查是否授权:
<ANDROID_SDK_HOME>\platform-tools>adb devices
List of devices attached
4df798d76f98cf6d unauthorized
2. Revoke USB Debugging on phone
2.取消手机上的USB调试
If the device is shown as unauthorized, go to the developer options on the phone and click "Revoke USB debugging authorization"(tested with JellyBean & Samsung GalaxyIII).
如果设备显示为未授权,请在手机的开发者选项中点击“撤销USB调试授权”(用JellyBean和三星GalaxyIII测试)。
3. Restart ADB Server:
3. 重启亚行服务器:
Then restarted adb server
然后重新启动 adb 服务器
adb kill-server
adb start-server
4. Reconnect the device
4. 重新连接设备
The device will ask if you are agree to connect the computer id. You need to confirm it.
设备会询问您是否同意连接计算机 ID。你需要确认一下。
5. Now Check the device
5. 现在检查设备
It is now authorized!
现在已经授权了!
adb devices
<ANDROID_SDK_HOME>\platform-tools>adb devices
List of devices attached
4df798d76f98cf6d device
回答by Quak
Ohhh finally I figured it out! After removing Eclipse directory I installed it into another directory.
啊啊啊终于想通了!删除 Eclipse 目录后,我将其安装到另一个目录中。
echo %ANDROID_SDK_HOME%
has displayed wrong path to sdk directory.
已显示错误的 sdk 目录路径。
set ANDROID_SDK_HOME "E:\adt-bundle-windows-x86_64-20140321\sdk"
- unplug device
adb kill-server
adb start-server
- plug device
set ANDROID_SDK_HOME "E:\adt-bundle-windows-x86_64-20140321\sdk"
- 拔掉设备
adb kill-server
adb start-server
- 插头装置
After these steps, I was able to see confirmation dialog with RSA fingerprint on my phone :)
完成这些步骤后,我可以在手机上看到带有 RSA 指纹的确认对话框:)
回答by e18r
Try forcing ADB to create new keys.
尝试强制 ADB 创建新密钥。
On Linux:
$ mv ~/.android/adbkey ~/.android/adbkey.old $ mv ~/.android/adbkey.pub ~/.android/adbkey.pub.old $ adb kill-server $ adb start-server
On Windows 10 (thank you, Pau Coma Ramirez, Naveenand d4c0d312!):
- Go to
%HOMEPATH%\Android\.android\
- Look for files called
adbkey
oradbkey.pub
. - Delete these files. Or, if you want to be on the safe side, move them to another directory.
- Repeat the above steps in
%USERPROFILE%\.android\
- Try again
- Go to
在 Linux 上:
$ mv ~/.android/adbkey ~/.android/adbkey.old $ mv ~/.android/adbkey.pub ~/.android/adbkey.pub.old $ adb kill-server $ adb start-server
在 Windows 10 上(谢谢Pau Coma Ramirez、Naveen和d4c0d312!):
- 去
%HOMEPATH%\Android\.android\
- 查找名为
adbkey
或 的文件adbkey.pub
。 - 删除这些文件。或者,如果您想安全起见,请将它们移动到另一个目录。
- 重复以上步骤
%USERPROFILE%\.android\
- 再试一次
- 去
After this I didn't even need to unplug my phone: the authorization prompt was already there. Good luck!
在此之后,我什至不需要拔掉手机:授权提示已经在那里了。祝你好运!
回答by user3787209
I run into the same issues with nexus7.
我遇到了与 nexus7 相同的问题。
Following worked for fixing this.
以下工作解决了这个问题。
Open
Developer
option in theSettings
menu on your device.Switch off
the button on the upper right of the screen.Delete
alldebug permission
from the list of the menu.Switch on
the button on the upper right of the screen.
打开设备菜单
Developer
中的Settings
选项。Switch off
屏幕右上角的按钮。Delete
全部debug permission
来自菜单列表。Switch on
屏幕右上角的按钮。
now reconnect your device to your PC and everything should be fine.
现在将您的设备重新连接到您的 PC,一切都应该没问题。
Sorry for my poor english and some name of the menus(buttons) can be incorrect in your language because mine is Japanese.
对不起,我的英语不好,菜单(按钮)的某些名称在您的语言中可能不正确,因为我的是日语。
回答by Tim Boland
I had the same problem. It was resolved by setting "USB computer connection" to "Camera (PTP)" instead of "Media Device (MTP)
我有同样的问题。解决方法是将“USB 计算机连接”设置为“相机 (PTP)”而不是“媒体设备 (MTP)”
回答by alexgophermix
I wasted hours on this stupid issue. None of the above solutions worked for me on their own.
我在这个愚蠢的问题上浪费了几个小时。上述解决方案均不适合我自己。
I'm running Windows 10. I had an old manual install of the Android SDK as well as Android Studio's SDK. I deleted my manually installed SDK and all my devices stopped working. These were the symptoms:
我正在运行 Windows 10。我有一个旧的 Android SDK 手动安装以及 Android Studio 的 SDK。我删除了手动安装的 SDK,所有设备都停止工作。这些是症状:
$ adb usb
error: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
as well as
也
$ adb devices
List of devices attached
id1 unauthorized
id2 unauthorized
id3 unauthorized
To be honest I'm not sure which of these steps got me my Allow USB debugging?prompts back so I listed EVERYTHING for completeness. Goes in order from easiest to hardest. Most people seem to be back on their feet after the first two sections.
老实说,我不确定这些步骤中的哪一个让我允许 USB 调试?提示回来,所以我列出了所有内容以确保完整性。从最简单到最难的顺序。大多数人似乎在前两个部分之后重新站起来。
Restart ADB
重启亚行
I would perform this after each of the sections below.
我将在下面的每个部分之后执行此操作。
adb kill-server
adb usb
Go crazy with developer options
为开发者选项疯狂
- Turn Developer optionsoff and back on
- Turn USB debuggingoff and back on
- Revoke USB debugging authorizations. Try this while USB debuggingis on and if possible try also when USB debuggingis off.
- 关闭并重新打开开发人员选项
- 关闭并重新打开USB 调试
- 撤销USB调试授权。在USB 调试打开时尝试此操作,如果可能,请在USB 调试关闭时尝试。
Replug devices
重新插入设备
- Unplug and replug USB cable into phone.
- Switch physical ports on your PC that your USB cable is connected into
- Switch physical USB cables you're using to connect your devices
- 将 USB 数据线拔出并重新插入手机。
- 切换 PC 上 USB 电缆连接到的物理端口
- 切换用于连接设备的物理 USB 电缆
Start rebooting everything
开始重启一切
- Reboot all your devices and connect again
- Reboot your PC
- Toggle WIFI on and off
- 重新启动所有设备并再次连接
- 重启你的电脑
- 打开和关闭 WIFI
Start deleting things
开始删除东西
- CAUTIONDelete your
~/.android
folder. Sometimes this folder can have the wrong permissions which can cause issues. You might want to back this folder up first. - Uninstall all manufacturer specific drivers from add/remove programs. I uninstalled the following (names are not exact)
- LG United USB Driver
- HTC Mobile USB Driver
- OnePlus USB Drivers 1.00
- Samsung USB Driver
- I also uninstalled all emulators and their respective drivers (optional)
- Nox & related drivers
- Bluestacks
- Genymotion
- 小心删除您的
~/.android
文件夹。有时,此文件夹可能具有错误的权限,这可能会导致问题。您可能想先备份此文件夹。 - 从添加/删除程序中卸载所有制造商特定的驱动程序。我卸载了以下(名称不准确)
- LG United USB 驱动程序
- HTC 移动 USB 驱动程序
- 一加 USB 驱动程序 1.00
- 三星 USB 驱动程序
- 我还卸载了所有模拟器及其各自的驱动程序(可选)
- Nox 和相关驱动程序
- 蓝叠
- 基因运动
Erase all Android related environment variables.
清除所有与 Android 相关的环境变量。
- Delete
%ANDROID_HOME%
if you have it set - Delete
%ANDROID_SDK_HOME%
if you have it set
%ANDROID_HOME%
如果设置了就删除%ANDROID_SDK_HOME%
如果设置了就删除
At this point all my devices magically came to life and started displaying the Allow USB debugging?prompts and connecting properly through ADB. If you've made it this far and haven't found a solution, I am truly sorry you're in this predicament. Make sure you've restarted all devices and your dev machine at the end of all of these steps and connect to a fresh USB port using a new cable.
此时,我所有的设备都神奇地活跃起来并开始显示允许 USB 调试?提示并通过亚行正确连接。如果您已经做到了这一点并且还没有找到解决方案,我真的很抱歉您处于这种困境。确保在所有这些步骤结束时重新启动所有设备和开发机器,并使用新电缆连接到新的 USB 端口。
If that still doesn't work try some of these other SO posts on the subject:
如果这仍然不起作用,请尝试有关该主题的其他一些 SO 帖子:
回答by himi
For reference, I just encountered much the same issue on Linux and had a hell of a time figuring it out. I eventually determined that I had a ~/.android directory that was root owned (thanks to running adb as root, while flailing around trying to figure out other connection problems). Deleting that root owned ~/.android directory resolved the missing authorisation dialog next time I reconnected the device.
作为参考,我刚刚在 Linux 上遇到了同样的问题,并且花了很长时间才弄清楚。我最终确定我有一个 root 所有的 ~/.android 目录(感谢以 root 身份运行 adb,同时试图找出其他连接问题)。删除 root 拥有的 ~/.android 目录解决了下次我重新连接设备时丢失的授权对话框。
It's possible that simply changing the ownership would also have fixed the problem - I'm guessing it was a simple lack of access to the adb key file stored inside that was the root of the problem. I didn't verify that, though, and I'm not going to deliberately break my hard-won connectivity just so I can check ;-)
简单地更改所有权也可能解决了问题 - 我猜这是一个简单的缺乏对存储在其中的 adb 密钥文件的访问权限,这是问题的根源。不过,我没有验证这一点,而且我不会故意破坏我来之不易的连接,以便我可以检查;-)
回答by vovahost
Steps that worked for me:
1. Disconnect phone from usb cable
2. Revoke USB Debugging on phone
3. Restart the device
4. Reconnect the device
The most important part was rebooting the device. Didn't work without it .
对我有用的步骤:
1. 断开手机与 USB 电缆的连接
2. 取消手机上的 USB 调试
3. 重新启动设备
4. 重新连接设备
最重要的部分是重新启动设备。没有它就无法工作。
回答by ShihabSoft
As the message have stated, you need to allow the adb access on your phone.
正如消息所述,您需要允许手机上的 adb 访问。
You need to first connect the phone to your PC with USB cables, then the authorization message will pop out on the screen. Tick remember your choice, then allow it.
您需要先用USB线将手机连接到PC,然后屏幕上会弹出授权信息。勾选记住您的选择,然后允许它。
IF your device doesnt shows any messages when connected to the PC.Just do this.
如果您的设备在连接到 PC 时没有显示任何消息,请执行此操作。
Remove /data/misc/adb/adb_key, reboot your phone and try connect again. The message should come up.
删除/data/misc/adb/adb_key,重启手机并再次尝试连接。该消息应该出现。
回答by GDefender
I was getting this error with my Nexus 10. I tried all of the answers I could find, and then I realized I was using a different USB port than usual. I switched to using the port I usually use, which is on the other side of my laptop, and the authorization popped up on my tablet!
我的 Nexus 10 出现此错误。我尝试了我能找到的所有答案,然后我意识到我使用的 USB 端口与平时不同。我切换到使用我通常使用的端口,这是在我的笔记本电脑的另一侧,并且授权在我的平板电脑上弹出!