Solve the problem that ADB cannot connect to the Android device! Reason: device unauthorized!

Attention! Start now!

This pit I fell is really a sinkhole! It's not as simple as what is said on the Internet, just plug in the USB cable, restart the USB debugging, and restart the Android device to solve it! ! ! I restore the factory settings and re-flash the system, but it doesn’t work. It’s just the last step of the USB debugging authorization. In layman's terms, the Android device does not trust this computer, which causes ADB to be unable to connect to the Android device. . . .

The following window never pops up:

Insert picture description here

WTF! I really don’t understand why this window did not pop up. I changed two USB cables, restarted the USB debugging N times, restarted the Android device N times, even restored the factory settings twice, and brushed the system once. But! Still unable to solve this problem. Besides, I cried.
Insert picture description here

problem

  • Input adb devicesand output information:
C:\Users\Administrator>adb devices
adb server version (31) doesn't match this client (41); killing...
could not read ok from ADB Server
* failed to start daemon
adb.exe: failed to check server version: cannot connect to daemon

Is such that:

C:\Users\Administrator>adb devices
adb server version (31) doesn't match this client (41); killing...
* daemon started successfully
List of devices attached
00000000000000000000    unauthorized
  • Input adb shelland output information:
C:\Users\Administrator>adb shell
adb.exe: 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.

However, when I connect with the 360 ​​mobile assistant, the window pops up normally, and the connection is normal:

Insert picture description here

The 360 ​​mobile phone demo looks like this:

Insert picture description here

Huh. . . There must be a ghost in this matter! Why can 360 mobile assistant connect normally? Can't use adb?

And I used another computer to test, and the USB debugging authorization can be popped up normally, and the adb connection is successful. It proves that the Android device and the data cable are no problem, the hardware problem is eliminated, and the software problem is left.

Solution

The core question is:This adb server's $ADB_VENDOR_KEYS is not set

Find the ~\.androiddirectory, usually in C:\Users\Administrator\.androidthis directory, focus on the three files adb_usb.ini, adbkey and adbkey.pub.

Insert picture description here

  • adb_usb.ini file, which is 设备VID, for example, mine is 0x2207
  • adbkey file, after checking this file, the 内容为空,这就是问题所在!
    general adbkey file content is like this:
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoI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OLG4M3yqrN1eksh4mUrgc51rkF1
0PvkzSlLwPYEjG4EW9Yc2sw7QzqqV2A8Ycn10js1pOYcyca3z5uPFYzMUUoiOBgY
/aFq6ekvMEEm5d78GJ6vAoJ1N2qXf6ajMhseBtu8WPqim1sKNQIWZtogiwKBgHS/
tENWESVSjdVuPB39YkNMRYjnaF64M89WA9P1KchDCFpbShudnfzuMC6q2bj4DvCa
ZwCstonQeSryyi/NZ0FtVA1Xr4qtszkYlNgWEnOz4CRD/PV3CoGUkeDw9VbLQvPF
jMMzQt1TxESYV0ajwGHxclMjikMxHwp1XADhJ/GFAoGBAL5zFXPFPfzsjEZMeUWq
8iYEH7AngolstAet4fn+JPPlB+H1wjNH7VblkfRKfBL+BeHHjQEVs0WWrG3dxqtE
S9I2NZ4n+9D9VtyP7GanMycG6pjKgcXKeUOU9mx8LNpeR8Dpdmh6IYcYmPlW6oWQ
Yu5AzjXHQPAJByl/Pg6O2o2H
-----END PRIVATE KEY-----

  • The adbkey.pub file, after checking this file, the 内容也为空,这就是问题所在!
    content of the adbkey.pub file generally looks like this:
QAAAAI2wW267bcJGPoGcqoCyVALniizZk3HWv9P2kqaNvQ0NTBUFQIobipl5Tzj/qPMl/XF6KKdMzoXaJusQV8I1iStXSgFsHcdsLITS7ei/Jpq+I+pd8R7C6oKzaW6UMCJpxGdp7hmgcAv87unYWsHpNYhOvQjjzOR6RXpCgHkW8xQMGpf9DKPSyu6l0bjtivoBiWlgU6pkSEXkzCnVTKjcPFfYnEV00Tj7SZh8sRdxsy/l3jFEumeE5KBkSBRTNjWYfeFBSiyETsXZYOFFsYctScKsKoB5b4+kSmvbKn/UkES1eGFONA4nGsFFplwnWAfcliCBUZf4GYWMGQIlW1j1c6LeQvqwO9q00nASoQ0Ln7NccjKY7Kh6CcWAKsFHViaF6W3+R2aJ3Ir3a6Iy4rRen/9j6ehGKmITlR0HJoX1F5ET3CkCc2Lc3hJYegCHqIJNQi4jNkwR6FP+6xgCDaZXftf2kpySHyGRzHHCnp9ytAzK52CDXiIaUdaSlzbFzx6bVLfhpZY3k4xIKdLg0XYxUKLFqyhc9Jraz13qV/U+onE/BELaSvT5MhM4QrltXLVz5/+/l7YN2fWT/tVRzjyUem5iHiWbG0EKGtw1Zsl/zdypVDwQvH9kvvn68jr2FeSElU4GURI5QmKP/shna+Nxt0/GKx1X0q8vuwhNQv0ZCseK0NEplAEAAQA= @unknown

The above two files are very important. Before the Android device confirms the authorization of USB debugging, the PC needs to generate a key and send the public key to the Android device, and the Android device will pop up a dialog box asking whether to allow USB debugging .

Normally,, 重启adb或者重启电脑就能生成adbkey私钥和配套的adbkey_pub公钥but it is obvious that I did not generate this. As for why it could not be generated, it is not very clear. . . . . . . .

How to generate these two files again? The method I use here is to find another computer and connect the Android device with adb on the computer. At this time, the ~\.androiddirectory will contain the three files above, and then copy them to my computer. If you have a better way, you can leave me a comment, everyone can learn together, thank you very much!

After copying the above files, you need to restart adb:

adb kill-server
adb start-server

After restarting adb, plug the usb cable into the computer, a pop-up window should appear to confirm that USB debugging is allowed, and the problem is solved.

Thank you very much for seeing here, it would be my honor to help you!

Guess you like

Origin blog.csdn.net/qq_36270361/article/details/108739423