Can't connect Nexus 4 to adb: unauthorized

181,137

Solution 1

I had similar situation. Here is what I did:

Try to check and uncheck the USB Debugging option in the device. (if not working, try to unplug/plug the USB)

At some point, the device should show up a messagebox to ask you if you authorize the computer. After you click yes, the device is then authorized and the connection is hooked.

Solution 2

I solved this problem without deleting any keys. Here's how:

  1. My device was connected to my computer via USB
  2. I made sure Eclipse and android device monitor weren't running.
  3. Typed at the commandline prompt: adb kill-server
  4. Typed at the commandline prompt: adb start-server
  5. After adb was restarted, I got a prompt on my device to authorize which I allowed.

Solution 3

Сhange USB connection mode from MTP to Camera (for Nexus 7) or, possibly, to Mass Storage or something else (for other devices). This option is usually under Settings -> Storage. Then connect the device again, you'll get the authorization dialog.

MTP has been known to interfere with USB debugging -- these two did not work together at all on majority of older devices. Nexus 7 and many newer devices do allow both to work alongside, but this particular issue suggests it's not all that smooth yet.

Bonus -- checklist for when adb is not behaving well:

  • adb kill-server followed by adb start-server
  • (on device) Settings -> Developer Options -> USB Debugging -- switch off and on
  • [Windows] Make sure you have the proper driver (your best bet is Universal Adb Driver by Koushik Dutta -- will handle any device)
  • [Windows] Try turning off all fancy on-the-fly anti-malware scanners/firewalls
  • [Linux] Make sure you have the proper UDEV rule in /etc/udev/rules.d/51-android.rules (again, universal solution: https://github.com/snowdream/51-android)
  • [Linux] Make sure everything under ~/.android is owned by you, not root (and upvote this answer)
  • restart device (yes, surprisingly, this is a valid measure, too)
  • (Obviously) replug cable, try different cable, different port, remove any extender cables

Solution 4

I think it has an error when the device tries to display the screen asking for permission, so it does not appear.

This works for me (commands are given in the adb shell):

  1. rm /data/misc/adb/adb_keys;
  2. I sent the public key (adbkey.pub in ~/.android/) from my computer to my device via email;
  3. Invoke stop adbd;
  4. cat adbkey.pub >> /data/misc/adb/adb_keys (authorize myself);
  5. start adbd (restart adb with new keys).

Solution 5

After you ensure you have enabled USB debugging unlock your phone and plug it into your machine via USB. You will be then asked to authorize communication with the computer you have connected to. It will also show computers RSA key fingerprint.

enter image description here

Accept it and you are good to go!

Share:
181,137

Related videos on Youtube

orS
Author by

orS

Updated on May 01, 2020

Comments

  • orS
    orS about 4 years

    I have a Nexus 4 with Android 4.3 and I am trying to connect the device to a computer with Windows 7 64bit.

    I installed the latest drivers and the latest adb version. I think I tried almost everything and I still get the following message:

    C:\Program Files (x86)\Android\sdk\platform-tools>adb devices
    List of devices attached
    007667324ccb229b        unauthorized
    

    What can be the reason for this error?

  • orS
    orS almost 11 years
    didn't work... important thing to mention: i tried to connect the device to other computer with windows xp and it's worked with no problems. so i guess that the problem not lies in the usb cable or the device itself, but, i can't find any reason that the problem lies in the computer... thanks!!
  • Tastybrownies
    Tastybrownies over 10 years
    This also worked for me. There was a prompt asking me to accept an RSA key. Never used to be this much trouble just a couple of years ago. Someone is messing things up...
  • BrainSlugs83
    BrainSlugs83 over 10 years
    Had to use "taskkill /F /IM adb.exe" -- the "/F" is for force. When I tried it without "/F" it told me it could not be terminated and that I had to use "/F".
  • BrainSlugs83
    BrainSlugs83 over 10 years
    Is "~/.android/" a Linux path? -- Where would we find this on Windows?
  • BrainSlugs83
    BrainSlugs83 over 10 years
    ... Found it, it's under "%HOMEDRIVE%%HOMEPATH%\.Android", which is IMO a really odd place to put things (at least in Windows -- application data should be stored under %AppData%...).
  • BrainSlugs83
    BrainSlugs83 over 10 years
    In addition, I also deleted adbkey.pub from my desktop machine, and /data/misc/adb/adb_key from my android device. -- I did get prompted -- and ADB started working again for a time -- but soon after it dies and goes back into Offline mode, no clue why.
  • Alejandro Mezcua
    Alejandro Mezcua over 10 years
    Worked for me in a Galaxy S4 with which I can not connect with the USB cable. Now I can at least connect to it with adb wirelessly.
  • Kaleb
    Kaleb over 10 years
    This worked for me on Windows 7 after I uninstalled the old driver and selected the "delete driver" checkbox... and then reinstalled the new driver to the device.
  • Danny Parker
    Danny Parker over 10 years
    Note that after 'adb start-server' you should see '* daemon not running. starting it now on port XXXX ' followed by ' daemon started successfully *' If you don't then the kill-server part didn't work and you may need to kill all instances of adb from your task manager/activity monitor.
  • gnac
    gnac over 10 years
    Only way to do it if you don't have a usb connection for whatever reason.
  • barconr
    barconr about 10 years
    This worked nicely. It seemed to force the windows 7 machine to re-install the driver.
  • Diederik
    Diederik about 10 years
    Solved it for my Nexus 4. Thanks
  • MiloDC
    MiloDC almost 10 years
    This is the correct answer. Merely un-checking then re-checking the debug option for USB connections did nothing for me, and neither did unplugging then reconnecting the USB cable. After I did adb kill-server then adb start-server then un-checked USB debugging then re-checked USB debugging, it worked.
  • Jonathan
    Jonathan over 9 years
    Wow - that finally worked! I've been trying for hours to try to get my Nexus 7 to bring up the auth dialog. For future reference, in order to change the USB connection mode, you have to go into Settings, Storage and hit the menu icon button in the top right - talk about obscure! I had neither MTP or Camera checked, but as soon as I checked the Camera option, the dialog came up (with it plugged in of course).
  • Rob
    Rob over 9 years
    Yes I downloaded the USB driver, enabled USB debugging, and had this issue. I had to unplug/replug the S4 in, then I got the 'authorize' prompt within S4. Now adb devices shows "device" and i can run my apps.
  • user1985189
    user1985189 over 9 years
    This authorize message never came up for me until I disabled Windows AutoPlay by unchecking "Use AutoPlay" for all media and devices."
  • sigmabeta
    sigmabeta over 9 years
    This answer should be higher - recent versions of Android Studio force you to move your SDK directory out of the AS installation path. Doing this on Windows without moving the ANDROID_SDK_HOME environment variable will result in devices showing as unauthorized.
  • dpb
    dpb over 9 years
    Thanks for the answer the link -- perfect. Permission problem on ~/.android
  • Richard Jones
    Richard Jones about 9 years
    This answer solved the problem I was having: my device was authorised but then somehow "forgot". I tried any number of things to fix it, but the "adb kill-server" ended up doing the job.
  • Drew Dormann
    Drew Dormann about 9 years
    I went pretty far down the list of answers, but this solution finally solved it.
  • leewz
    leewz almost 9 years
    This... this actually worked. My ANDROID_SDK_HOME was set to ...\Android\sdk when the folder was at ...\Android\android-sdk. Changing it and opening a new Command Prompt (to use the updated environment variables) got me the popup after starting adb-devices again.
  • Zoltán
    Zoltán almost 9 years
    "[Linux] Make sure everything under ~/.android is owned by you, not root (and upvote this answer)" - is what fixed it for me. Thanks!
  • Big Rich
    Big Rich over 8 years
    Thanks, this was the most simple way, I ran adb kill-server && adb start-server as it's a one-liner. I like this method as my development team also use the android device, and reseting the developer option, as suggested elsewhere, might be an inconvenience for the rest of the team.
  • Ian Wong
    Ian Wong over 8 years
    This method is especially good when you have brick'd your device.
  • Admin
    Admin over 8 years
    1. unplug, remove all passed allowed devices, replug, check remember, 2. ? 3. profit!
  • Ryan R
    Ryan R over 8 years
    I just had to wait about a minute and the Authorization Box appeared on the device.
  • Sujan Shrestha
    Sujan Shrestha over 8 years
    Thanks for sharing. Deleting adbkey file and restarting the adb worked for me.
  • Markon
    Markon over 8 years
    This should be the accepted answer...! Thanks a lot.
  • Petter Kjelkenes
    Petter Kjelkenes about 8 years
    Changing to USB connection mode from MTP to Camera worked for me on Samsung Galaxy Xcover 3
  • sritmak
    sritmak almost 8 years
    Also check if echo %ANDROID_SDK_HOME% is set to the right path
  • MBX
    MBX almost 8 years
    My phone can't start it is in a boot loop, I cannot enable USB Debugging, How can i do!
  • fantaghirocco
    fantaghirocco almost 8 years
    this should be Community Wiki
  • Deko
    Deko over 7 years
    You just ended my 2.5h frustration !!
  • Yoraco Gonzales
    Yoraco Gonzales over 7 years
    Thanks that solved the problem: - Unplug the device - Wait until a dialog ask to permitt the computer to access the device
  • Arild
    Arild over 7 years
    In my case, the phone screen is black (lights up on interaction, sound on etc, there is just no picture). Is there a way to accomplish this without going through the phone UI?
  • kkost
    kkost over 6 years
    you saved me, thank you. Why nobody in the whole internet didn't mentioned permission issue....
  • Vaz
    Vaz about 6 years
    My solution started similarly but it ended up requiring a simple fix for the unix file permissions in ~/.android on the host machine (not phone). See my answer if this one didn't quite do it for you: stackoverflow.com/a/23231640/1064996 . Just FIY since some people found this solution was close but not quite (like for me).