Search code examples
androidadbunauthorized

Android 8.0 adb device keeps unauthorized after authorisation


Edit: I did some deeper investigation, but still no clue what causes the problem.

  • When I plugin my usb cable the phone asks: "Allow access to phone data"
  • I'm sure I have allowed the access but keep getting unauthorized
adb usb
error: device unauthorized. Please check the confirmation dialog...

adb devices
ce051605a5378d1b03      unauthorized

adb connect 192.168.1.6
unable to connect to 192.168.1.6:5555

Connecting over wifi also doesn't work, that is the correct ip as I setted it fixed.

What can be the cause and how can I fix it? Running on Samsung Android 8.0 and connected to PC Win7 x64.


Solution

  • If you're using Windows follow these steps, after i tried every solution and almost gave up i found the following and it worked.

    • First things first:
    • Phone: Check if you have a file called adb_keys located at: /data/misc/adb/adb_keys. If you have it, i would recommend you to backup the file. (I didn't have it.)
    • Windows: You'll need to have a file called adbkey.pub located at C:/users/UserAccount/.android/

    • Boot into recovery mode.

    • Plug your phone into PC.
    • Open cmd and run adb devices. It would show "recovery" instead "unauthorized".

    • Create a new file called adb_keys file on your PC:

      type NUL > adb_keys
      
    • Now you need to copy the contents from the adbkey.pub to adb_keys, the new file you just created: adbkey.pub is located at C:/users/UserAccount/.android/ (Needless to say you need to replace "UserAccount" when running the command)

      type c:\users\UserAccount\.android\adbkey.pub > adb_keys
      
    • Upload the adb_keys file to your phone:

      adb push adb_keys /data/misc/adb/adb_keys
      
    • Reboot and run adb devices. It should be working now.

    Thank mnoguti from this post on XDA-Developers for this answer.

    If you have Linux that's the same solution with Unix commands.