安卓ADB设备未经授权问题

145

配置:

  • Windows 8.1
  • ADB 版本:1.0.32
  • 智能手机:OnePlus One

问题:

我按要求安装了三星驱动,但运行 ADB devices 命令时出现未授权的提示。

已尝试:

  1. 我已尝试这篇帖子中提到的所有方法:https://dev59.com/7WAg5IYBdhLWcg3w3eJi#25546300

    但问题是,我的手机上没有提示我接受连接。

  2. 当我运行adb shell命令时,输出如下:

    error: device unauthorized.
    This adbd's $ADB_VENDOR_KEYS is not set; try 'adb kill-server' if that seems wrong.
    Otherwise check for a confirmation dialog on your device.
    

    我执行了"adb kill-server",但它没有改变任何东西。为什么呢?


在尝试了以上所有方法后,我开始下载较低版本的AVD以查看是否有其他版本可以使用。API 28和27仍然在启动时冻结,但API 26可以正常启动。Android Studio 3.1.3。我将尝试在以后卸载并重新安装,但很高兴这最终又可以正常工作了。在经历了近一个星期的关键进程错误而没有解决之后,在进行了全新的Windows 10安装后,我进行了Android Studio 3.1的全新安装。 - Jon
24个回答

4

这个页面列出的方法都没有对我起作用,具体情况如下:

  • 当我选择撤销USB调试授权时,设置应用程序会崩溃。
  • 我使用的是LineageOS 14 x86_64。
  • 我正在使用网络ADB。
  • /data/misc/adb中没有adb_keys文件。
  • 删除本地的~/.android/adbkey并没有帮助。
  • 我从本地终端获得了root访问权限。
  • 我没有收到任何确认对话框。
adb: error: failed to get feature set: 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.
- waiting for device -

最终,我发现了一篇非常有用的文章这里,建议手动将~/.android/adbkey.pub文件中的内容放入/data/misc/adb/adb_keys文件中。
他们提出了以下两种方法之一:
  1. From another working device, copy the adb_keys file into your computer:

    # On the other Android device
    cp /data/misc/adb/adb_keys /sdcard
    
    # From your computer
    adb pull /sdcard/adb_keys .
    

    Then put the working adb_keys file into the problematic Android device's sdcard (using Web or MTP) named as adb_keys, then copy the file into the correct path:

    # On the problematic device
    cp /sdcard/adb_keys /data/misc/adb/adb_keys
    
  2. The other method is to simply copy your machine's adbkey.pub from the ~/.android/ directory, and put it into the problematic Android device's sdcard (using Web or MTP) named as adb_keys, then copy the file into the correct path:

    # On the problematic device
    cp /sdcard/adbkey.pub /data/misc/adb/adb_keys
    

    (Note: there's a similar answer on SO that goes into further details for this method.)

由于我在我的电脑上运行了一个Web服务器,并且我已经在Android上安装了curl,因此我从终端中使用su并在我的Android设备上运行了以下命令:

cd /data/misc/adb
curl 192.168.1.35:8080/adbkey.pub > adb_keys

使用adb kill-server命令终止adb守护进程,然后突然间adb shell正常工作,就像一开始应该的那样。

希望这里描述的方法对您起到了和我一样的作用。


2
  1. First Remove the adbkey and adbkey.pub from the .android directory in your Home directory.
  2. Make .android directory in your home with 710 permissions: $ chmod 710 .android/ and ownership as: chown -R <user>:<user> .android/. Ex:

    $ chmod 710 .android/
    $ chown -R ashan:ashan .android/
    
  3. Go to developer options in your mobile and tap option Revoke USB debugging authorizations

  4. Turn off all USB Debugging and Developer Options in the device and disconnect the device from your machine.

  5. Connect the device again and at first turn on the Developer Options. Then Turn on the USB debugging.

  6. At this point in your mobile, you will get a prompt for asking permission from you. Note: you must check the checkbox always accept from this …. option and click ok.

  7. Now in you machine, start the adb server: adb start-server.

  8. Hopefully when you issue the command: adb devices now, you will see your device ready authorized.


1
你的应用被检测为一些有害程序。关闭“通过USB验证应用”选项。该选项在与“USB调试”相同的视图中。

1
尝试从C/.android文件夹中删除adbkey文件,然后按照上述命令运行,即:执行

adb kill-server, adb start-server和adb devices

.


看起来,这正是在 https://dev59.com/Z1wZ5IYBdhLWcg3wROmO#55470951 帖子中详细描述的内容。 - Manohar Reddy Poreddy

1
我也遇到了这个问题。我在Nexus 5X上使用我的自定义AOSP构建。我在build/core/main.mk中添加了一行代码:
diff --git a/core/main.mk b/core/main.mk
index a6f829ab6..555657539 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -362,6 +362,8 @@ else # !enable_target_debugging
   ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
 endif # !enable_target_debugging

+ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
+
 ## eng ##

 ifeq ($(TARGET_BUILD_VARIANT),eng)

现在adb shell已经正常工作。
这些资料很有用(中文文章):http://www.voidcn.com/blog/kc58236582/article/p-6335996.html, http://blog.csdn.net/fanmengke_im/article/details/28389439

0
这对我有用:
rm ~/.android/adbkey.pub
sudo ./adb kill-server sudo ./adb start-server sudo ./adb -s emulator-5554 install ~/apk_to_install.apk
我不确定是否以sudo特权运行adb是一个好主意,但这是我唯一能让它工作的方法。问候。

0

我作为非root用户尝试连接自定义恢复(Philz)时遇到权限错误,但是作为root用户却没有问题。所以我杀掉了adb服务器,将我的用户帐户的.android子目录复制到/root中,使用chown -R更改所有者为root.root,并重新启动adb服务器。现在我可以连接成功了!


0

我在重新安装了我的Android Studio之后遇到了同样的问题。以下是我所做的使adb再次工作的方法:

-path to C:\Users\User\AppData\Local\Android\sdk\platform-tools
-Shift+r.click and start command from here instead.

0

对于任何以后遇到此问题的人也许可以帮助。我尝试从用户命令提示符使用adb时遇到了这个问题,上面的答案没有帮助,但在管理员命令提示符下运行“adb kill-server”可以解决问题。


0

您只需要授权调试模式即可。
1. 确保您的设备已连接到电脑。
2. 通过Android-Studio允许授权调试模式,方法是进入
Run -> Attach debugger to Android process
然后您将在设备上看到弹出窗口以允许调试模式,
按下“确定”即可完成。
希望对某些人有所帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接