简体   繁体   English

无法将Nexus 4连接到adb:未经授权

[英]Can't connect Nexus 4 to adb: unauthorized

I have a Nexus 4 with Android 4.3 and I am trying to connect the device to a computer with Windows 7 64bit. 我有一个带有Android 4.3的Nexus 4,我正在尝试将设备连接到装有Windows 7 64bit的计算机。

I installed the latest drivers and the latest adb version. 我安装了最新的驱动程序和最新的adb版本。 I think I tried almost everything and I still get the following message: 我想我几乎尝试了一切,但仍然得到以下消息:

C:\Program Files (x86)\Android\sdk\platform-tools>adb devices
List of devices attached
007667324ccb229b        unauthorized

What can be the reason for this error? 这个错误的原因是什么?

I had similar situation. 我有类似的情况。 Here is what I did: 这是我做的:

Try to check and uncheck the USB Debugging option in the device. 尝试检查并取消选中设备中的USB调试选项。 (if not working, try to unplug/plug the USB) (如果不工作,请尝试拔下/插上USB)

At some point, the device should show up a messagebox to ask you if you authorize the computer. 在某些时候,设备应该显示一个消息框,询问您是否授权计算机。 After you click yes, the device is then authorized and the connection is hooked. 单击“是”后,将授权该设备并连接该连接。

I solved this problem without deleting any keys. 我没有删除任何键就解决了这个问题。 Here's how: 这是如何做:

  1. My device was connected to my computer via USB 我的设备通过USB连接到我的电脑
  2. I made sure Eclipse and android device monitor weren't running. 我确保Eclipse和Android设备监视器没有运行。
  3. Typed at the commandline prompt: adb kill-server 在命令行提示符下键入:adb kill-server
  4. Typed at the commandline prompt: adb start-server 在命令行提示符下键入:adb start-server
  5. After adb was restarted, I got a prompt on my device to authorize which I allowed. 重新启动adb后,我的设备上有一个提示,要求我允许我进行授权。

Сhange USB connection mode from MTP to Camera (for Nexus 7) or, possibly, to Mass Storage or something else (for other devices). Сhange从MTP到相机 (用于Nexus 7)的USB连接模式,或者可能用于大容量存储或其他设备(用于其他设备)。 This option is usually under Settings -> Storage . 此选项通常位于Settings -> Storage Then connect the device again, you'll get the authorization dialog. 然后再次连接设备,您将获得授权对话框。

MTP has been known to interfere with USB debugging -- these two did not work together at all on majority of older devices. 众所周知,MTP会干扰USB调试 - 这两者在大多数旧设备上根本无法协同工作。 Nexus 7 and many newer devices do allow both to work alongside, but this particular issue suggests it's not all that smooth yet. Nexus 7和许多新设备确实允许两者同时工作,但是这个特殊问题表明它并不是那么顺利。

Bonus -- checklist for when adb is not behaving well: 奖金 - 当adb表现不佳时的清单:

  • adb kill-server followed by adb start-server adb kill-server后跟adb start-server
  • (on device) Settings -> Developer Options -> USB Debugging -- switch off and on (在设备上) Settings -> Developer Options -> USB Debugging - 关闭然后再打开
  • [Windows] Make sure you have the proper driver (your best bet is Universal Adb Driver by Koushik Dutta -- will handle any device) [Windows]确保你有合适的驱动程序(最好的选择是Koushik Dutta的Universal Adb Driver - 将处理任何设备)
  • [Windows] Try turning off all fancy on-the-fly anti-malware scanners/firewalls [Windows]尝试关闭所有花哨的动态反恶意软件扫描程序/防火墙
  • [Linux] Make sure you have the proper UDEV rule in /etc/udev/rules.d/51-android.rules (again, universal solution: https://github.com/snowdream/51-android ) [Linux]确保在/etc/udev/rules.d/51-android.rules有适当的UDEV规则(再次,通用解决方案: https//github.com/snowdream/51-android
  • [Linux] Make sure everything under ~/.android is owned by you, not root (and upvote this answer ) [Linux]确保~/.android下的所有内容都归您所有,而不是root (并提供此答案
  • restart device (yes, surprisingly, this is a valid measure, too) 重启设备(是的,令人惊讶的是,这也是一个有效的措施)
  • (Obviously) replug cable, try different cable, different port, remove any extender cables (显然)重新插入电缆,尝试不同的电缆,不同的端口,移除任何扩展器电缆

I think it has an error when the device tries to display the screen asking for permission, so it does not appear. 我认为当设备尝试显示要求许可的屏幕时出错,因此它不会出现。

This works for me (commands are given in the adb shell ): 这对我adb shell (命令在adb shell中给出):

  1. rm /data/misc/adb/adb_keys ; rm /data/misc/adb/adb_keys ;
  2. I sent the public key (adbkey.pub in ~/.android/) from my computer to my device via email; 我通过电子邮件将公钥(adbkey.pub在〜/ .android /中)从我的电脑发送到我的设备;
  3. Invoke stop adbd ; 调用stop adbd ;
  4. cat adbkey.pub >> /data/misc/adb/adb_keys (authorize myself); cat adbkey.pub >> /data/misc/adb/adb_keys (授权给自己);
  5. start adbd (restart adb with new keys). start adbd (使用新密钥重新启动adb)。

After you ensure you have enabled USB debugging unlock your phone and plug it into your machine via USB. 确保已启用USB调试后,请解锁手机并通过USB将其插入计算机。 You will be then asked to authorize communication with the computer you have connected to. 然后,系统会要求您授权与已连接的计算机进行通信。 It will also show computers RSA key fingerprint. 它还将显示计算机RSA密钥指纹。

在此输入图像描述

Accept it and you are good to go! 接受它,你很高兴!

1.) Delete ~/.android/adbkey on your desktop machine 1.)删除桌面计算机上的〜/ .android / adbkey

2.) Run command "adb kill-server" 2.)运行命令“adb kill-server”

3.) Run command "adb start-server" 3.)运行命令“adb start-server”

You should now be prompted to accept debug key. 现在应该提示您接受调试密钥。

Four easy steps 四个简单的步骤

./adb kill-server ./adb start-server ./adb kill-server ./adb start-server

replug the device, unlock it and accept the new key 重新插入设备,解锁并接受新密钥

Similar to Flavio's answer ( https://stackoverflow.com/a/18542792/1064996 ), it was something to do with the files in ~/.android (on the host machine, not the phone). 与Flavio的答案( https://stackoverflow.com/a/18542792/1064996 )类似,它与~/.android的文件有关(在主机上,而不是手机上)。

I didn't have ~/.android/adbkey , but I did have ~/.android/debug.keystore and my whole ~/.android directory was owned by root. 我没有~/.android/adbkey ,但我确实有~/.android/debug.keystore ,我的整个~/.android目录由root拥有。 I removed the keystore file and also changed ownership to me ( sudo chown -R $USER ~/.android ), killed the adb server and plugged in my phone, and it worked. 我删除了密钥库文件,并将所有权更改为我( sudo chown -R $USER ~/.android ),杀死了adb服务器并插入了我的手机,它运行正常。

It was probably the ownership thing. 这可能是所有权的事情。 Make sure you have read/write permissions in ~/.android 确保你在~/.android有读/写权限

For my Samsung S3, I had to go into Developer Options on the phone, untick the "USB debugging" checkbox, then re-tick it. 对于我的三星S3,我不得不进入手机上的开发者选项,取消选中“USB调试”复选框,然后重新勾选它。

Then the dialog will appear, asking if you want to allow USB Debugging. 然后会出现对话框,询问您是否要允许USB调试。

Once I'd done this, the " adb devices " command no longer showed " unauthorized " as my device name. 完成此操作后,“ adb devices ”命令不再显示“ 未授权 ”作为我的设备名称。

(Several months later..) (几个月后..)

Actually, the same was true for connecting my Galaxy Tab S device, and the menu options were in slightly different places with Android 4.4.2: 实际上,连接我的Galaxy Tab S设备也是如此,菜单选项与Android 4.4.2略有不同:

在此输入图像描述

Here is my version of the steps: 这是我的步骤版本:

  1. Make sure adb is running 确保adb正在运行
  2. In device go to Settings -> developer options -> Revoke USB debugging authorities 在设备中,转到设置 - >开发人员选项 - >撤消USB调试权限
  3. Disconnect device 断开设备
  4. In adb shell type > adb kill-server 在adb shell类型> adb kill-server中
  5. In adb shell type > adb start-server 在adb shell类型> adb start-server中
  6. Connect device 连接设备

if adb shell shows empty host name, restart device 如果adb shell显示空主机名,请重启设备

Had the same issues getting an authorization token on my Nexus 5 on Windows 8.1. 在Windows 8.1上的Nexus 5上获得授权令牌时遇到同样的问题。 I didn't have the latest adb driver installed - this is visible in device manager. 我没有安装最新的adb驱动程序 - 这在设备管理器中可见。 Downloaded the latest ADB USB driver from Google here: http://developer.android.com/sdk/win-usb.html 从这里下载了最新的ADB USB驱动程序: http//developer.android.com/sdk/win-usb.html

Updated the driver in device manager, however enable/disable USB debugging and unplugging/plugging USB still did not work. 更新了设备管理器中的驱动程序,但启用/禁用USB调试和拔出/插入USB仍然无法正常工作。 Finally the "adb kill-server" and "adb start-server" mentioned in other answers did the trick once the driver was updated. 最后,一旦驱动程序更新,其他答案中提到的“adb kill-server”和“adb start-server”就会成功。

Had the same issue. 有同样的问题。 Not sure if these are the same steps for Windows as I'm using an OS X device but you can try: 不确定这些步骤是否与我使用OS X设备的步骤相同,但您可以尝试:

  1. Reboot your phone into recovery mode. 将手机重新启动到恢复模式。
  2. Connect it to your computer. 将其连接到您的计算机。
  3. Open the terminal and type: 打开终端并输入:

     cd ~/.android adb push adbkey.pub /data/misc/adb/adb_keys 
  4. All done! 全部完成! Just adb shell reboot and feel the power! 只需adb shell reboot并感受到力量!

  1. Make sure adb is up to date 确保adb是最新的
  2. Make sure you are using the google usb drivers: http://developer.android.com/tools/extras/oem-usb.html 确保您使用的是谷歌USB驱动程序: http//developer.android.com/tools/extras/oem-usb.html
  3. Make sure your ANDROID_SDK_HOME environment variable is set to the correct path 确保将ANDROID_SDK_HOME环境变量设置为正确的路径

I reinstalled the usb drivers and ensured that I was not using USB 3.0 port. 我重新安装了usb驱动程序并确保我没有使用USB 3.0端口。

I then closed out eclipse and killed and restarted adb . 然后我关闭了eclipse并杀死并重新启动了adb

Was immediately prompted on phone to allow computer access. 立即通过电话提示允许计算机访问。 After accepting I restarted eclipse and now my Galaxy S3 shows up in device Device Manager. 接受后我重启了eclipse,现在我的Galaxy S3显示在设备设备管理器中。

对我来说,一旦我禁用了MTP(在设置>存储>菜单> MTP中),我终于得到了RSA提示

If you are on adb over network, try to connect via USB instead or vice versa. 如果您使用adb通过网络,请尝试通过USB连接,反之亦然。 This did the trick for me. 这对我有用。 After accepting it once it always works later on. 一旦接受它,它总是在以后工作。

This kind of an old post and in most cases I think the answer that has been upvoted the most will work for people. 这种旧帖子,在大多数情况下,我认为最受欢迎的答案将适用于人们。

In Lollipop on a GPE HTC M8 I was still having problems. 在棒棒糖上的GPE HTC M8上我仍然遇到问题。 The below steps worked for me. 以下步骤对我有用。

  1. Go to Settings 前往设置
  2. Tap on Storage 点击存储
  3. Tap on 3 dots in the top right 点击右上角的3个点
  4. Tap on USB Computer Connection 点击USB计算机连接
  5. UNCHECK MTP UNCHECK MTP
  6. UNCHECK PTP UNCHECK PTP
  7. Back in your console, type adb devices 返回控制台,输入adb devices

Now you should get the RSA popup on your phone. 现在你应该在手机上获得RSA弹出窗口。

I was not getting the RSA fingerprint pop up on my phone. 我的手机上没有弹出RSA指纹。

I had to delete the C:\\Users\\<userName>\\.android\\adbkey and adbkey.pub files and then do kill and restart of adb server. 我不得不删除C:\\Users\\<userName>\\.android\\adbkeyadbkey.pub文件,然后杀死并重新启动adb服务器。

adb kill-server
adb start-server

I had to stop and restart the debugger and connecting as USB in PTP mode. 我必须停止并重新启动调试器并在PTP模式下作为USB连接。

Because the RSA authorisation key was getting stored in this path, killing and restarting the adb server didn't help. 由于RSA授权密钥已存储在此路径中,因此终止并重新启动adb服务器无济于事。

I was able to solve this one by following the steps listed here: http://forum.xda-developers.com/showthread.php?t=2247471 我可以按照此处列出的步骤解决此问题: http//forum.xda-developers.com/showthread.php?t = 2247471

delete the computers adb key: rm /data/misc/adb/adb_key on device 

(I have no idea if in case of multiple authorized computers the additional keys are in a new line of the file or if they are in new files. I have only 1 computer.)

stop all adb processes "killall adb" in linuxoids and "taskkill /IM adb.exe" in windows or simply the taskmanager in both.

restart the phone

toggle usb debugging off and on

connect

use adb

click authorize

I had to re-install my adb driver to snap out of this probelm. 我不得不重新安装我的adb驱动程序以快速解决这个问题。 I had install "Universal Naked Driver" in an effort to recover my phone. 为了恢复手机,我安装了“Universal Naked Driver”。 I uninstalled that and re-installed the driver out of the android sdk. 我卸载了它并重新安装了驱动程序的android sdk。

When I turn off my Comodo Antivirus everything goes back normal. 当我关闭我的Comodo Antivirus时,一切都恢复正常。 All other solutions suggested here went in vain. 这里建议的所有其他解决方案都是徒劳的。 Somehow I figured out one solution. 不知怎的,我想出了一个解决方案。

If you are using Comodo Antivirus (Version 6.3/ For other versions search for similar options) the following solution would help you. 如果您使用的是Comodo Antivirus (版本6.3 /其他版本搜索类似选项),以下解决方案将对您有所帮助。

Open Comodo > Tasks > Advanced Tasks > Open Advanced Settings > Security Settings > Firewall > Firewall Settings > Advanced : Filter loopback traffic (eg 127.xxx, ::1) 打开Comodo>任务>高级任务>打开高级设置>安全设置>防火墙>防火墙设置>高级: 过滤环回流量(例如127.xxx,:: 1)

Uncheck this "Filter loopback traffic" option, which prevents adb from normal working. 取消选中 “过滤环回流量”选项,可防止adb正常工作。

Use a different USB cable. 使用其他USB电缆。 Some cables may not have all pins connected or whatnot, and while they work for image transfer, the debugging/adb does not work. 某些电缆可能没有连接所有引脚或诸如此类,并且当它们用于图像传输时,调试/ adb不起作用。

The bottom line: I kid you not. 底线:我没骗你。 A cable which works for my phone (adb works) does NOT work for my tablet - the device is always offline or unauthorized and tablet pops out no dialog. 适用于我的手机(adb工作)的电缆不适用于我的平板电脑 - 设备始终处于脱机状态或未经授权,平板电脑不会弹出对话框。 I tried multiple reboots, settings, I went berserk in the process and cursed the bloody Android. 我尝试了多次重启,设置,我在这个过程中疯狂,并诅咒血腥的Android。 Then accidentally I plugged in the cable which came with the tablet and suddenly it worked. 然后我不小心插上了平板电脑附带的电缆,然后突然工作了。 My fascination with Android is definitely gone. 我对Android的迷恋肯定不见了。 What a stupid piece of junk. 多么愚蠢的垃圾。

It happened for me after my backup software changed the permission to my user directory. 在我的备份软件将权限更改为我的用户目录后,它发生在我身上。 I opened it in File Explorer, it prompted me to set permissions and it fixed the issue. 我在文件资源管理器中打开它,它促使我设置权限,它解决了问题。

FYI: Android has a special directory under "\\User\\.android" If you can't access it, it won't prompt you. 仅供参考:Android在“\\ User \\ .android”下有一个特殊目录如果您无法访问它,它将不会提示您。

My resolution was running adb devices from the command prompt, pathed to the adb application. 我的解决方案是从命令提示符运行adb devices ,将其打到adb应用程序。 For example C:\\Android\\platform-tools\\adb devices . 例如C:\\ Android \\ platform-tools \\ adb devices。 Running this command returned the following * daemon not running. starting it now on port 5037 * *daemon started successfully * 运行此命令会返回以下* daemon not running. starting it now on port 5037 * *daemon started successfully * * daemon not running. starting it now on port 5037 * *daemon started successfully *

I then saw the device listed as unauthorized, unplugges the USB, plugged back in and was prompted for the RSA fingerprint. 然后我看到设备被列为未经授权的设备,拔掉USB插头,重新插入并提示输入RSA指纹。

I was facing same, issue, I found I was using a simple usb cable which was meant for only charge and not data copy. 我面临同样的问题,我发现我使用的是简单的usb电缆,仅用于充电,而不是数据复制。 using good usb cable solved my problem ! 用好USB线缆解决了我的问题!

简单地重新插入就可以解决这个问题了......第一次插入设备时,权限对话框没有出现,第二次出现,现在一切都很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM