adb无法连接,设备未unauthorized,没有usb调试授权弹框勾选

1. cmd 窗口日志

C:\Users\fadi.su>adb devices
List of devices attached
GA9XSGUGZP4HOJOJ        unauthorized

C:\Users\fadi.su>adb shell
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.

对应adb 源码

  • system/core/adb/transport.cpp
atransport* acquire_one_transport(TransportType type, const char* serial, TransportId transport_id,
                                  bool* is_ambiguous, std::string* error_out,
                                  bool accept_any_state) {
  ...
    if (result && !accept_any_state) {
        // The caller requires an active transport.
        // Make sure that we're actually connected.
        ConnectionState state = result->GetConnectionState();
        switch (state) {
            case kCsUnauthorized: {
                *error_out = "device unauthorized.\n";
                char* ADB_VENDOR_KEYS = getenv("ADB_VENDOR_KEYS");
                *error_out += "This adb server's $ADB_VENDOR_KEYS is ";
                *error_out += ADB_VENDOR_KEYS ? ADB_VENDOR_KEYS : "not set";
                *error_out += "\n";
                *error_out += "Try 'adb kill-server' if that seems wrong.\n";
                *error_out += "Otherwise check for a confirmation dialog on your device.";
                result = nullptr;
                break;
            }
  ...

2. 解决方法

初次使用手机时,在开发者模式中勾选开发者模式

或者多次重试如下步骤

  1. 进入手机的开发者模式
  2. 撤销usb调试授权
  3. 重新打开开发者模式

如果上述都不行,考虑更换USB驱动,重启电脑和手机,最差的情况下,这台手机不允许使用adb调试,不弹出usb调试授权

3. 第一次可用,突然就不可用的解决方法

  1. C盘搜索 “.android”
  2. 进入.android目录,删除 adbkey 和 adbkey.pub
  3. 重新插拔下,看是否可以弹出 usb调试授权

adb无法连接,设备未unauthorized,没有usb调试授权弹框勾选_第1张图片

你可能感兴趣的:(Android系统)