[android] How to solve ADB device unauthorized in Android ADB host device?

When I'm using a rooted Android device as ADB host to send adb command "adb devices" to Samsung S4, I received device unauthorized error message. However when I tried adb to Samsung Galaxy Nexus, it is working fine. Can anyone advise how to solve my Samsung S4 problem?

=========================================
# adb devices
List of devices attached
4d00f9169907301b        unauthorized
=========================================

Thanks in advance.

Edit: Found that this problem only happened to Android 4.2.2 and above. The following link explained that Google has implemented some new security features for using adb.

http://nelenkov.blogspot.com/2013/02/secure-usb-debugging-in-android-422.html

Appreciate if anyone can help on this.

This question is related to android shell adb

The answer is


You need to allow Allow USB debugging when the popup shows up when you first connect to the computer!


You must be prompted in your s4 screen to authorize that computer. You can tell it to remember it. This is for security reasons, occurring in Android 4.4+


If anyone has similar issue of having a phone with a cracked screen and has a need to access adb:

  1. Root your phone (mine was already rooted, so I was blessed at least with that).

If you forgot to enable developers mode and your adb isn't running, then do the following:

  1. Reboot your phone into recovery.
  2. Connect the phone with a cable.
  3. Open terminal.
  4. If you type adb devices you should see the device in the list.
  5. If so, type:

    adb shell mount /system
    abd shell
    
    echo "persist.service.adb.enable=1" >> default.prop 
    echo "persist.service.debuggable=1" >> default.prop
    echo "persist.sys.usb.config=mtp,adb" >> default.prop
    echo "persist.service.adb.enable=1" >> /system/build.prop 
    echo "persist.service.debuggable=1" >> /system/build.prop
    echo "persist.sys.usb.config=mtp,adb" >> /system/build.prop
    

Now if you are going to reboot into your phone android will tell you "oh your adb is working but please tap on this OK button, so we can trust your PC". And obviously if we can't tap on the phone stay in the recovery mode and do the following (assuming you are not in the adb shell mode, if so first type exit):

cd ~/.android
adb push adbkey.pub /data/misc/adb/adb_keys
  1. Hurray, it all should be hunky-dory now! Just reboot the phone and you should be able to access adb when the phone is running:

    adb shell reboot

P.S. Was using OS X and Moto X Style that's with the cracked screen.


Delete the folder .android from C:/users/<user name>/.android. It solved the issue for me.


Experience With: ASUS ZENFONE

If at all you have faced Missing Driver for Asus Zenfones Follow This Link (http://donandroid.com/how-to-install-adb-interface-drivers-windows-7-xp-vista-623)

I tried with

1) Killing and starting adb server at adb cmd.

2) Switching Usb Debugging on and Off and ...

This is What WORKED with me.

Step 1:Remove Connection with Device and Close Eclipse

Step 2:Navigate to C:/Users/User_name/.android/

Step 3:You Will Find adb_key

Step 4:Just delete it.

Step 5.Connect again and System will ask you Again.

Step 6.Ask Device to remember RSA Key when it Prompts. I think its done.

If you Face The Same Problem after couple of days, just disable and enable USB debugging


Check and uncheck the USB Debugging option in the device. If that doesn't work unplug and plug in the USB a couple of times.

At some point, the device should show a message box to ask you to authorize the computer. Click yes and then the device will be authorized.


For unknown reasons, I only had ~/.android/adbkey, but not ~/.android/adbkey.pub.

I guess that adb was unable to push the public key to the device, and thus the device could never show the authorization dialog.

After killing the adb server, removing the adbkey file and starting adb again, the authorization dialog popped up on the phone.


For me, the emulator could not have Google Play Services enabled. It could have Google APIs or be x86 or x64 but not google play store.


Have you tried

adb kill-server
adb shell

Sometimes adb gets stuck and first killing adb server and then starting some command forces authorization window to pop-up.

Also please check adb client version on your phone. THis feature is supported from adb 1.0.31 as far as I remember.


I found one solution with Nexus 5, and TWRP installed. Basically format was the only solution I found and I tried all solutions listed here before: ADB Android Device Unauthorized

Ask Google to make backup of your apps. Save all important files you may have on your phone

Please note that I decline all liability in case of failure as what I did was quite risky but worked in my case:

Enable USB debugging in developer option (not sure if it helped as device was unauthorized but still...)

Make sure your phone is connected to computer and you can access storage

Download google img of your nexus: https://developers.google.com/android/nexus/images unrar your files and places them in a new folder on your computer, name it factory (any name will do).

wipe ALL datas... you will have 0 file in your android accessed from computer.

Then reboot into BOOTLOADER mode... you will have the message "you have no OS installed are you sure you want to reboot ?"

Then execute (double click) the .bat file inside the "factory" folder.

You will see command line detailed installation of the OS. Of course avoid disconnecting cable during this phase...

Phone will take about 5mn to initialize.


Try this steps:

  1. unplug device
  2. adb kill-server
  3. adb start-server
  4. plug device

You need to allow Allow USB debugging in your device when popup.


I had to check the box for the debugger on the phone "always allow on this phone". I then did a adb devices and then entered the adb command to clear the adds. It worked fine. Before that, it did not recognize the pm and other commands


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to shell

Comparing a variable with a string python not working when redirecting from bash script Get first line of a shell command's output How to run shell script file using nodejs? Run bash command on jenkins pipeline Way to create multiline comments in Bash? How to do multiline shell script in Ansible How to check if a file exists in a shell script How to check if an environment variable exists and get its value? Curl to return http status code along with the response docker entrypoint running bash script gets "permission denied"

Examples related to adb

ADB server version (36) doesn't match this client (39) {Not using Genymotion} ADB device list is empty "unable to locate adb" using Android Studio Run react-native on android emulator Solving "adb server version doesn't match this client" error Adb install failure: INSTALL_CANCELED_BY_USER Session 'app': Error Installing APK Where is adb.exe in windows 10 located? How to debug in Android Studio using adb over WiFi Set adb vendor keys