ChatGPT解决这个技术问题 Extra ChatGPT

ADB Android Device Unauthorized

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.

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:

[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?

https://i.stack.imgur.com/ZWtny.jpg

https://i.stack.imgur.com/tnf0A.jpg

Random guess, but what if you delete all debug authorizations in settings on the phone.
I did it but nothing happens...
USB Drivers reinstalled - still nothing.
Worked for me first time +1
1. unplug, 2. goto the developer menu, 3. remove all allowed devices, 4. replug the usb to your pc, 5. on the pop-up on your phone select remember, click allow, done! 6. ? 7. profit!

M
Michael G

It's likely that the device is no longer authorized on ADB for whatever reason.

1. Check if authorized:

<ANDROID_SDK_HOME>\platform-tools>adb devices
List of devices attached
4df798d76f98cf6d        unauthorized

2. Revoke USB Debugging on phone

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).

3. Restart ADB Server:

Then restarted adb server

adb kill-server
adb start-server

4. Reconnect the device

The device will ask if you are agree to connect the computer id. You need to confirm it.

5. Now Check the device

It is now authorized!

adb devices
<ANDROID_SDK_HOME>\platform-tools>adb devices
List of devices attached
4df798d76f98cf6d        device

Step two was not necessary here, but couldn't find that menu either.
The device didn't ask (or I didn't see it ask) if to agree to reconnect, but after following the above steps, then turn off and turn back on usb-debugging, it worked.
Didn't work for me; Android 6.0 Marshmallow has no option "Revoke USB debugging authorization." Note: after killing ADB, I get "This adbd's $ADB_VENDOR_KEYS is not set; try 'adb kill-server' if that seems wrong"; as well as "error: device unauthorized" etc.
I can't find option "Revoke USB debugging authorization" on Android 4.4.4. Where is it?
If your device doesn't prompt for authorization it might be because the account you're running adb from doesn't have permission to handle keys. If this happens to you, try it elevated permissions (e.g. sudo).
c
cglacet

Try forcing ADB to create new keys.

On Linux/OSX: $ 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, Naveen and d4c0d312!): Go to %HOMEPATH%\Android\.android\ Look for files called adbkey or adbkey.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 %HOMEPATH%\Android\.android\

Look for files called adbkey or adbkey.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

After this I didn't even need to unplug my phone: the authorization prompt was already there. Good luck!


None of the other answers worked, this one nailed it! Thanks a lot! =)
For Windows check the keys in %HOMEPATH%\.android\ or %USERPROFILE%\.android\ . Thank you, This one worked for me!
@Naveen that's probably the issue. Delete adbkey.pub and try again to see if both keys get regenerated.
Thank you! On Windows 10, this is what got it working for me.
On Windows 10 you need to delete both %HOMEPATH%\Android\.android\ and %USERPROFILE%\.android\
R
Reaz Murshed

Ohhh finally I figured it out! After removing Eclipse directory I installed it into another directory.

echo %ANDROID_SDK_HOME%

has displayed wrong path to sdk directory.

set ANDROID_SDK_HOME "E:\adt-bundle-windows-x86_64-20140321\sdk" unplug device adb kill-server adb start-server plug device

After these steps, I was able to see confirmation dialog with RSA fingerprint on my phone :)


it's not showing debug enabling dialog...any suggestion here!
Setting the environment variable worked for me, but I had to perform a reboot for it to take effect.
In my case an environment variable of ANDROID_HOME_SDK point to 'E:\android-sdk\SDK Manager.exe' which wrong. so, after I change to 'E:\android-sdk' I try to echo like him said but enviroment seem not to update. so, I restart pc -> unplug usb -> adb kill-server -> adb start-server -> plug usb -> work !
I was using adb kill-server and adb start-server that doesn't work but when when unplug device and use these the command it worked thanks!
Steps 2-5 helped me. The only weird thing - step 4 did not work without sudo. I mean, it did start the server, no errors. But authorization popup did not appear on the phone. (And after step 2 I've cleared all stored authorizations on the device, not sure if it was important)
H
Harpreet Singh

I run into the same issues with nexus7.

Following worked for fixing this.

Open Developer option in the Settings menu on your device. Switch off the button on the upper right of the screen. Delete all debug permission from the list of the menu. Switch on the button on the upper right of the screen.

now reconnect your device to your PC and everything should be fine.

Sorry for my poor english and some name of the menus(buttons) can be incorrect in your language because mine is Japanese.


This worked for me. step 3 seemed vague, but for that I "revoked usb debugging authorization." When I connected the device back up (after enabling debugging options and usb debugging again) it prompted me to save the computer's RSA key. Thanks :)
This worked for me on a Wiko Lenny. Disconnect device, switch Developer mode off, revoke debug permissions, turn Developer options back on, reconnect device, re-enable USB debugging.
After trying to fix this for a while, Revoke USB Debugging Authorization now makes my emulator hard-reset. Quality.
T
Tim Boland

I had the same problem. It was resolved by setting "USB computer connection" to "Camera (PTP)" instead of "Media Device (MTP)


Only way is working for my ID 1004:631d LG Electronics, Inc. Optimus Android Phone (Camera/PTP Mode) Thank you!
this worked for me too.. on redmi note 3 NitrogeOS 7.1.2
Did it for me on OnePlus One Lineage 14.1.
Worked for me on a Samsung Galaxy S4 Active.
I connected my Samsung Galaxy S21 5G running Android 11 to my Mac Mini (2018) running macOS 11.6, but my phone wasn't prompting for authorization. I changed "Use USB for" from "Transferring files / Android Auto" to "Transferring images" and that worked
C
Community

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:

$ 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.

Restart ADB

I would perform this after each of the sections below.

adb kill-server
adb usb

Go crazy with developer options

Turn Developer options off and back on Turn USB debugging off and back on Revoke USB debugging authorizations. Try this while USB debugging is on and if possible try also when USB debugging is off.

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

Start rebooting everything

Reboot all your devices and connect again Reboot your PC Toggle WIFI on and off

Start deleting things

CAUTION Delete 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

Erase all Android related environment variables.

Delete %ANDROID_HOME% if you have it set Delete %ANDROID_SDK_HOME% if you have it set

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.

If that still doesn't work try some of these other SO posts on the subject:

Android ADB device offline, can't issue commands

Can't connect Nexus 4 to adb: unauthorized

How to solve ADB device unauthorized in Android ADB host device?


None of the other suggestions here worked, but this one got me on the right tracks. The ~/.android directory part is almost right. After a recent Android Studio update for SDK adb stopped working, with exectly these symptoms. In the end I found out that ~/.android/adbkey and ~/.android/adbkey.pub were both 0-sized files, so I've deleted them, restarted adb server, et voila! Got my auth prompt immediatelly.
Also had joy deleting ~/.android
Thanks. Deleting ~/.android solved it for me after having done everything else and staying there for long as well!
@EvanCarroll you just need to delete ~/.android/adbkey
Deleting the adbkey file did it for me. After I reset device, pc etc and deleting this;
h
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.

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 ;-)


To me, the issue was the ~/.android folder lacked the adbkey.pub file.
v
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 .


From my experience working with AndroidTV devices I remember them behaving the same as a normal phone so you should try it out.
K
Khamidjon Khamidov

For me, I firstly unauthorized my device accidentally which I found out later. To revert it back to reauthorise:

Disconnect USB device from laptop/computer Click 'Revoke USB debugging authorisations' in Developer options. Disable developer options on top. re-enable it again. enable USB debugging run command 'adb kill-server' on terminal run command 'adb start-server' on terminal connect your mobile device to laptop/computer reauthorize press like)

Note: if above doesn't work, trying restarting your laptop before connecting again


In my case This WORKED!!!
S
Shimmy Weitzhandler

After having spent over an hour going in rounds swearing at Samsung (mostly), Google, and who not, here are my findings, that finally helped me get the device recognized:

On Device: Set developer mode Allow USB debugging Default USB configuration > Select USB tethering Connect device to PC USB On PC: Elevated cmd/ps prompt (maybe not mandatory, but that was my drill) adb kill-server (precede with .\ in ps) adb start-server (while device connected) > watch for prompt on device On device: Always allow connections from this computer > Yes On PC: adb devices gets the following output:

List of devices attached
278c250cce217ece        device

C
Community

Had similar issue on osx and Nexus 5 (A6.0.1). I did get the authorization pop-up and confirmed it, despite that Android Studio nor any other IDE could connect to device.

Turned out my Nexus (rooted) was missing key files.

Rebooted Android device into recovery

Ran code pasted below

Rebooted Android device, adb now identifies device

Push key from computer to Android device:

 cd ~/.android && adb push adbkey.pub /data/misc/adb/adb_keys

Solution came from here


THIS is the answer for a device which can't show an ADB authorization dialog (like when having a custom kernel installed)
G
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!


S
ShihabSoft

As the message have stated, you need to allow the adb access on your phone.

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.

IF your device doesnt shows any messages when connected to the PC.Just do this.

Remove /data/misc/adb/adb_key, reboot your phone and try connect again. The message should come up.


Still no message. I don't know what to do now :( I don't want debug on emulator...
Unplug and replug works! This scenario occurs when enabling USB debugging for the first time.
M
Marc.2377

The solution is to copy your file ~/.android/adbkey.pub (on GNU/Linux, or %USERPROFILE%\.android\adbkey.pub on Windows) to Android, and place it as /data/misc/adb/adb_keys. You need root privileges to do that.

You can transfer the file any way you like (or are able to), be it USB, e-mail or a temporary file upload service. In my case, as it was a new Android-x86 installation in a Virtual Machine, no usable web browser, and with network/TCP adb not working, I had to actually type in the 715 characters.

At least it worked.


S
Samson Maosa

If you are on ubuntu, try running the server as root:

sudo adb kill-server

sudo adb start-server


this one helped me on Ubuntu 19.10 and Amazon Fire 7, thanks!
I dunno why, but running with sudo works. Ubuntu 20.04.1
S
Sakkeer Hussain

I was tiered with this, I got that permission dialog by turning off wi-fi of my phone.


i
isXander

Disconnect your device from the computer.

Go into developer settings.

Turn off developer settings.

Turn on developer settings.

Enable USB Debugging (and whatever other settings you enabled beforehand)

Reconnect your device to the computer.

Try again.

Worked for me so hope it works for you!


Worked immediately for me. Mush easier than most of these other methods. Thank you!
g
gaus

Simply, turn off developer options from your device and again turn on, attach USB with the device and working system and turn on USB debugging.


This has already been mentioned in other answers. When answering older questions that already have answers, please make sure you provide either a novel solution or a significantly better explanation than existing answers.
In my case this worked for me.
l
lakme.1989

I was not getting the RSA fingerprint pop up on my phone.

I had to go into the

  C:\Users\<userName>\.android\adbkey and adbkey.pub 

files, delete those and then do kill and restart of adb server. I had to stop and restart the debugger and connecting as USB in PTP mode.

Because the RSA authorisation key was getting stored in this path, killing and restarting the adb server didn't help.


O
Ofir Attal

This solved my issue!

run your android simulator go to setting and enable developer mode enable from the developer settings usb debugging

at this point you will get popup massage at you emulator to authorise the device and you are good to go :)


J
Jared Forth

You should delete the file: c:\users\_user_name_\.android\adbkey


This helped me along with following the 5-step process by @Martin. This can go between steps 2 and 3.
A
Alexmelyon

Recheck 'USB Debug' option in developer options helped me


n
not2qubit

On some Samsung devices the mode change that can be set by dialing *#0808# doesn't stick without direct reboot. Once rebooted, dial the same string and make sure that you have adb + mdp selected and USB set to AP. After this make sure to reconnect phone and restart ADB server. Also try to avoid USB hubs and virtual machines witch surely complicate matter further. The follow the previously mentioned instructions for clearing authorized devices etc.


Great! Works for Samsung Galaxy S5 Android 5.0 (OTA updated from KitKat). I should also mention that the issue only appeared on Windows 7 desktop. At windows 7 laptop and mini-mac it never asks for authorization!
R
Reaz Murshed

I had a similar problem. However, it was solved using a different solution. I thought I might share this here as well. Let me describe my problem first.

I had the Android SDK in my ubuntu. The path to the android SDK was not in the environment variable path. I installed adb using a apt-get command and it could not find the sdk home folder and hence, it was showing the unauthorized error and the device was not popping up anything as well. I got stuck here.

Then I uninstalled the adb using apt-get purge which I installed earlier. The Android SDK has the adb program in the platform-tools folder. I just add the path to the environment variable and it worked like a charm.

export PATH=${PATH}:/home/YOUR-USERNAME/path/to/adb
adb devices
List of devices attached
f7f716d56905    device

Hence the problem was not setting the Android SDK to the environment variable path.


H
Hasan A Yousef

The same issue started appearing once I changed my development device, it was solved as:

$ mv ~/.android/adbkey ~/.android/adbkey.old
$ mv ~/.android/adbkey.pub ~/.android/adbkey.pub.old
$ adb kill-server
$ adb start-server

v
voghDev

I had the same message in two phones:

- Sony Xperia E
- Samsung Galaxy Core 2

both Android 4.4.2, and i solved it with these two steps:

1.- Updating my adb to 1.0.31, downloading the latest version of Android SDK from SDK Manager

You can check your adb version by typing

adb version

2.- Once the phone is plugged in USB Debugging mode, A message appears asking you to authorize this computer for debugging. You have to mark "Always allow this computer", and click on Allow.

Hope it helps.


i update the android sdk plateform-tools and it's work thinks (y)
P
Pazel1374

it's not may work for all situations but because i used a long cable my device doesnt connect properly and the message wont pop up change the cable may solve the problem


L
Languoguang

I just try adb kill-server, it works for me:

PS C:\Users\languoguang> adb devices
List of devices attached
MKJ0117A19000186        unauthorized
PS C:\Users\languoguang> 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.

kill and start adb server:

PS C:\Users\languoguang> adb kill-server
PS C:\Users\languoguang> adb start-server
* daemon not running; starting now at tcp:12345
* daemon started successfully
PS C:\Users\languoguang> adb devices
List of devices attached
MKJ0117A19000186        device

d
double-beep

Here's what I did that that brought the authorization prompt and made my device appear. I used a Samsung Galaxy s7 edge.

Enable developer mode and USB debugging on your device. Revoke the USB debugging authorization Plug your phone to computer via USB. Drag notification panel and select "Software Installation" as shown in the image below This will begin installing USB driver and the prompt for USB debugging authorization will show.


C
Cristian Ciupitu

Check if you have Samsung Kies installed. That is one possible solution


Yup , in my case I wasn't using an of the shelf Android device , so I had to delete any previous adbkey files , and ask the device manufacturer to send me : adbkey and adbkey.pub ....but for regular devices , "Revoke USB Debugging on phone" seems to do the trick