152

Configuration:

  • Windows 8.1
  • ADB version: 1.0.32
  • Smartphone: Oneplus One

Problem

I installed the Samsung drivers as it is said to do. When I run the ADB devices command, it said unauthorized.

Already tried:

  1. I've done everything that'd been said on this post: https://stackoverflow.com/a/25546300/1848376

    But the problem is that I don't get a prompt on the phone to tell me I must accept the connection.

  2. When I run the command adb shell, here is the answer:

    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.
    

I did "adb kill-server", but it didn't change anything. Why?

1
  • After trying all of the above, I started downloading lower AVD's to see if any others would work. API 28 and 27 still freeze up during boot, but API 26 started right up. Android Studio 3.1.3 I will try to uninstall and reinstall at a later date, but glad this is finally working again. Fresh install of Android Studio 3.1 after a fresh Windows 10 install after dealing with critical process error for almost a week without rectification.
    – Jon
    Commented Jun 19, 2018 at 1:21

24 Answers 24

301
  1. Try Revoke USB DEBUGGING Authorization.
  2. Enable USB debugging again.

It worked.

7
  • 19
    When you re-enable USB debugging, it might be important to check the box that says always allow USB debugging from this device. I believe this option will only show up if you have your Android device plugged to USB when you are re-enabling USB debugging. Commented Aug 30, 2016 at 21:32
  • 1
    I only had to disable and then enable USB debugging on my device, after moving to a new computer (Macbook).
    – Nancy
    Commented Dec 22, 2016 at 16:30
  • Unplug then replug should be your first move anyway.
    – TGrif
    Commented Oct 9, 2018 at 19:50
  • I never thought I get myself trapped in the "did you try to turn it off an on again?" :)
    – jediz
    Commented Nov 12, 2019 at 21:24
  • there is no option to Revoke USB DEBUGGING Authorization
    – user924
    Commented Dec 24, 2020 at 0:41
61

Thankgod xda developers exist : http://forum.xda-developers.com/verizon-lg-g3/help/unable-to-access-adb-t2830087

Just had to delete adbkey file in C:Users/$Name/.android adbkey.pub was missing.

Restart after this and both files are there.

If this does not work : - Try Revoke USB DEBUGGING Authorization. - Enable USB debugging again.

7
  • 3
    where is this key on a Mac ?
    – mosaad
    Commented Oct 12, 2017 at 10:45
  • 1
    > Restart after this and both files are there As in reboot? I'm on Windows and am stuck with an "unauthorized" device that just won't go away! (But I haven't rebooted, cuz 2 millions windows open)
    – tbone
    Commented Jun 1, 2018 at 15:29
  • 3
    @tbone I know it's a late answer but you only need to restart the adb server. Commented Apr 10, 2019 at 20:07
  • 2
    deleted everything in that file and not only did it fix ADB over Network, but also USB
    – Ben
    Commented May 9, 2019 at 20:04
  • 2
    renamed to .android.old to be on the safe side, but as soon as I restarted adb server and revoked authorizations, my phone prompted me right away! @julestruong thanks! Commented Jun 3, 2019 at 23:08
41

In sequence:

    adb kill-server
  • in your DEVICE SETUP, go to developer-options end disable usb-debugging

  • press REVOKE USB debugging authorizations, click OK

  • enable usb-debugging

    adb start-server
    
1
  • 2
    I ran the command as root in Ubuntu and this solved my problem. Couldn't make it work without su (Ubuntu 18).
    – petobens
    Commented Oct 20, 2018 at 16:55
25

I removed the following files from the ~/.android folder:

  • adbkey
  • adbkey.pub

I disabled and enabled ADB within device and now it works...

1
  • 2
    I only saw adbkey file so I deleted it and it worked like charm. Thanks! Commented May 2, 2019 at 19:48
18

in Developer options,

  1. Enable USB debugging.

enter image description here

  1. Give a authorization.

enter image description here

(if there is no a Developer option menu, you have to click 3 times build number of Phone State menu to be developer. you can sse a developer option menu.)

enter image description here

17

Delete existing adbkeys

OR

Rename adbkeys

Best practise is to rename the keys because it provides backup.

cd ~/.Android

mv adbkey adbkey2

mv adbkey.pub adbkey.pub2

Next stop & start the server

cd ~/Android/Sdk/platform-tools

Locate the device /Android/Sdk/platform-tools$ ./adb devices

/Android/Sdk/platform-tools$ ./adb kill-server

/Android/Sdk/platform-tools$ ./adb start-server

Then, stop the emulator Open AVD manager, click on the down arrow, then click on wipe data

Restart the emulator. Then everything works fine :)

1
  • Didn't help. still get platform-tools adb devices -> List of devices attached -> 192.168.0.185:5555 unauthorized
    – Dr.jacky
    Commented Jan 13, 2023 at 14:04
17

This worked for me

1- Go to ~/.android/ and remove “adbkey”
2- Disconnect USB connection
3- adb kill-server
4- Revoke USB debugging authorizations (in developer option)
5- Reconnect the device to the Ma
6- adb devices
2
  • 2
    This was the only thing that worked for me. Thanks :) Commented Dec 16, 2020 at 6:56
  • The only thing that has worked for me after 2 hours of trying to get it to work... Commented Jul 16 at 21:18
9

Try this uncheck the "verify apps via USB" in developer options and then turn on and off the "USB Debugging". It works with me.

2
  • 1
    This method worked for me: My "USB Debugging" was ON at first, then I uncheck "verify apps via USB" but this doesn't help. After I turn on then on "USB Debugging", it worked!
    – Jackie Yeh
    Commented Jun 10, 2020 at 3:59
  • My device doesn't boot up. Commented Mar 19, 2021 at 16:14
5

Ensure that you have accepted the pressed the "ok" button when it is asking it is showing the fingerprint of the device after connecting through usb to your PC.

2
  • 2
    I wonder if people upvoting other answers actually checked the device screen… Commented Oct 5, 2018 at 13:06
  • LOL I felt pretty dumb when I looked down at my phone Commented Dec 13, 2018 at 0:55
4

In Android studio, Run menu > Run shows OFFLINE ... for the connected device.

Below is the procedure followed to solve it:

  1. (Read the below note first) Delete the ~/.android/adbkey (or, rename to ~/.android/adbkey2, this is even better incase you want it back for some reason)
    Note: I happened to do this step, but it didn't solve the problem, after doing all the below steps it worked, so unsure if this step is required.

  2. Run locate platform-tools/adb
    Note: use the path that comes from here in below commands

  3. Kill adb server:
    sudo ~/Android/Sdk/platform-tools/adb kill-server

  4. You will get a Allow accept.. message popup on your device. Accept it. This is important, which solves the problem.

  5. Start adb server:
    sudo ~/Android/Sdk/platform-tools/adb start-server

  6. In Android studio, do Run menu > Run again
    It will show something like Samsung ... (your phone manufacture name).
    Also installs the apk on device correctly this time without error.

Hope that helps.

4

None of the methods listed on this page worked for me; specifically:

  • I had an issue where the Settings app would crash when selecting Revoke USB debugging authorizations
  • I was running LineageOS 14 x86_64
  • I was using ADB over network
  • The /data/misc/adb contained no adb_keys file
  • Removing my local ~/.android/adbkey did not help either
  • I had root access from the local terminal
  • I was not getting any confirmation dialog
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 -

In the end, I found a very useful post here that suggested to manually put the contents of ~/.android/adbkey.pub inside the /data/misc/adb/adb_keys file.

They suggested one of these two methods:

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

Since I was running a web server on my computer, and I had curl installed on Android, I su'ed from the terminal and ran the following on my Android device:

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

Killed the adb daemon (using adb kill-server) and BAM! The adb shell worked fine, like it should have been from the beginning.

Hopefully, the method described here works for you as it did for me.

3
  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

I was hit by this problem, too. I'm using my custom build of AOSP on Nexus 5X. I've added a single line in 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)

Now adb shell works fine

Those materials are useful (Chinese articles): http://www.voidcn.com/blog/kc58236582/article/p-6335996.html, http://blog.csdn.net/fanmengke_im/article/details/28389439

1

Try deleting the adbkey file from C/.android folder

and then run the commands as mentioned above i.e.

adb kill-server, adb start-server and adb devices

.

1
1

Your app is being detected as some harmful program. Turn off "Verify apps over USB" option. It's in the same view as "USB debugging".

1
Disconnect USB between PC and device
Stop adb server by entering "adb kill-server" in command window
On device use "Revoke USB debugging authorizations" in "Developer Options"
On PC delete "adbkey" file in user directory, for example "C:\Users\Amit\.android"
Reconnect the device to the PC
Open a command window and enter "adb devices". Watch the device's screen for any Authorization message and allow the connection.
1
  • Adb devices shows the device (again) but says UNAUTHORISED and the pop up doesn't appear on the phone screen. I forced it to appear when opened android studio. Commented Apr 5, 2022 at 23:37
0

All you need is to authorize debug mode.
1. make sure your Device is connected to your PC.
2. Allow authorized for debug mode via Android-Studio by going to
Run -> Attach debugger to Android process
than you will see the pop up window for allow debug mode in your Device,
press OK. done.
i hope it help to someone.

0

I had the same problem after reinstalled my android studio. Here's what I did to make my adb work again:

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

for anyone encountering this later this may also help. I encountered this exact issue trying to use adb from a user command prompt and the answers above did not help, but the problem went away with an "adb kill-server" when running in an administrator command prompt.

0

This worked for me:

rm ~/.android/adbkey.pub

sudo ./adb kill-server

sudo ./adb start-server

sudo ./adb -s emulator-5554 install ~/apk_to_install.apk

I'm not sure if is a good idea run adb with sudo privileges,but it was the only way I get it works. Regards.

0

I got this as root when as a non-root user I was getting permissions errors trying to connect to custom recovery (Philz). so I killed adb server, copied the .android subdirectory of my user account into /root, chowned -R to root.root, and restarted adb server. I'm in!

-1

I suppose you have enabled On-device Developer Options in your smartphone? If not you can take a look at the steps provided by Android, http://developer.android.com/tools/device.html#developer-device-options

3
  • Yes i did, and i also switch it off and on.
    – julio
    Commented Jul 26, 2015 at 15:22
  • according to this link (code.google.com/p/android/issues/detail?id=175077), it seems "platform tools 23 rc1" has this problem. You can find platform tool versions with "$ adb version" cmd . The link says that switching back to build-tools version 22 fixes the issue. Commented Jul 26, 2015 at 15:33
  • I download plateform tools 22, and replaced it in sdk directory, didnt work (adb version seems to be the same though)
    – julio
    Commented Jul 26, 2015 at 15:53
-1

For FIRE STICK 4K it actually says in the dialog:

Otherwise check for a confirmation dialog on your device

Indeed on the TV in the other room there was a confirmation dialog. Doh'!

1
  • 1
    Maybe this could be a side comment to the question, but it's not an answer since the question is concerned with a different type of device.
    – Jairo
    Commented Aug 13, 2020 at 22:03
-2

I had this problem and it wasnt solved by the deleting of any keys (at least deleting them didnt fix it, maybe had an effect after i did fix it though)

I actually had a discrepancy between my sdk-tools version and my Android Studio version. After updating my tools it still didnt work, but after updating AS (to 1.4) everything worked fine again.

Always update both sdk-tools and AS version together ;)

Not the answer you're looking for? Browse other questions tagged or ask your own question.