ADB Android Device Unauthorized

2018-12-31 23:25发布

问题:

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?

USB Connection \"Via

Wireless Connection \"Via

回答1:

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


回答2:

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.

  1. setx ANDROID_SDK_HOME \"E:\\adt-bundle-windows-x86_64-20140321\\sdk\"
  2. unplug device
  3. adb kill-server
  4. adb start-server
  5. plug device

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



回答3:

I run into the same issues with nexus7.

Following worked for fixing this.

  1. Open Developer option in the Settings menu on your device.

  2. Switch off the button on the upper right of the screen.

  3. Delete all debug permission from the list of the menu.

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



回答4:

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



回答5:

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

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

Replug devices

  1. Unplug and replug USB cable into phone.
  2. Switch physical ports on your PC that your USB cable is connected into
  3. Switch physical USB cables you\'re using to connect your devices

Start rebooting everything

  1. Reboot all your devices and connect again
  2. Reboot your PC
  3. Toggle WIFI on and off

Start deleting things

  1. 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.
  2. 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
  3. I also uninstalled all emulators and their respective drivers (optional)
    • Nox & related drivers
    • Bluestacks
    • Genymotion

Erase all Android related environment variables.

  1. Delete %ANDROID_HOME% if you have it set
  2. 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?


回答6:

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 .



回答7:

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



回答8:

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.



回答9:

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!



回答10:

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



回答11:

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



回答12:

This solved my issue!

  1. run your android simulator
  2. go to setting and enable developer mode
  3. 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 :)



回答13:

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.



回答14:

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.



回答15:

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.



回答16:

Check if you have kies installed. That is one possible solution



回答17:

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.



回答18:

This is error because your window version haven\'t driver for usb 3.0 to receiver authenticate permission from phone. I spent 5 day with this bug. Now, install 58964_Intel(R)_USB_3.0 driver. And continue with awesome code!

i use this link to download driver



回答19:

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



回答20:

adb usb worked for me This restarts the adb daemon listening on the USB port The command returned:

error: device unauthorized. Please check the confirmation dialog on your device

. But the prompt for the RSA key showed up on the phone straight away. Once I approved, everything started working as expected



回答21:

After installing Android studio, I had incorrect permissions on the folder \"~/.android\"(access for reading and writing only for root). So I changed it and ran project from Android studio(device still was marked as \"unauthorized\").

Android studio showed an error \"Error installing apk\", but in the folder \"~/.android\" were created files \"adbkey\", \"adbkey.pub\", \"debug.keystore\".

After that I restarted adb (ran commands adb kill-server and adb start-server) and authorization dialog appeared on my device.

Hopefully someone will approach this solution.



回答22:

What I\'ve done to solve the issue was to disconnect and reconnect the usb cable to the USB port again (done with another port on my machine).

Then I have chose to charge and that\'s it. The mobile device asked me to grant access for the machine, I agreed and that\'s solved the issue.

When running adb devices, I saw the device in the list.

(Done in Windows 10 home).



回答23:

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


回答24:

Linux-Ubuntu-14.04
I read all the answer for this post, nothing worked for me :(
This may be because I am not using normal end User device, working on corporate device!

Thing worked for me is:
Get VID,PID for your device from lsusb and update 51-android.rules (https://source.android.com/source/initializing.html#configuring-usb-access)
Ensure adb_usb.ini is also updated with same VID, PID



回答25:

I tried many ways to solve this problem, this one works for me.

Install SnapPea on your PC. SnapPea

Plug your phone in USB Debugging mode and open SnapPea, a authorization dialog will show on your phone. The Dialog shows on the phone

Hope it helps.