Story
I like scrcpy. It allows me to cast my phone to computer and use it ther thanks to cable technology (wifi works too). So, after hopping to Pop_OS! I reinstalled adb and scrcpy.
But this time scrcpy didn't work. Instead it throw this error:
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.
ERROR: "adb push" returned with value 1
Easy way | Grant access using prompt on the phone
After enabling USB debugging in Developer options connect phone to computer and run scrcpy
. Phone should prompt you for granting access to computer. All you have to do is accept and connection will be granted 🎉️
This prompt didn't appear on my phone. As it turns out, that prompt doesn't works as expected on some custom ROMS. After some digging online, I came across this answer on stack overflow. Which leads to a commit message for (new) adb authentication implemented in 2012. This prompt copies ~/.android/adbkey.pub on computer, $ADB_VENDOR_KEYS
, to /data/misc/adb/adb_keys
file in phone's memory. since prompt isn't working for me I have to add that key manually 😕️
Littler harder way | copy-paste using Termux + root
Since /data/misc/adb/adb_keys
file is offlimits for the user, we need root priviledges for this method.
- Copy ~/.android/adbkey.pub to phone's memory
- Open Termux and install sudo >
pkg install tsu
- Navigate to where file adbkey.pub is. I'm using Redmi Note 4 and its
/sdcard
directory is used for .
File is at/sdcard/adbkey.pub
in my case >cd /sdcard
- Copy
adbkey.pub
to/data/misc/adb/adb_keys
with sudo priviledges >sudo cp adbkey.pub /data/misc/adb/adb_keys
- Double check if content of
/data/misc/adb/adb_keys
on phone and~/.android/adbkey.pub
on computer are the same - Enjoy 😊️
Hard way | copy-paste using TWRP
This is the "no-root" hard method. You will still need root priviledges to edit /data/misc/adb/adb_keys
. If your phone isn't rooted but has TWRP, GREAT. TWRP has root priviledges and a file manager.
- Boot into TWRP by holding Vol+ and Power keys while the phone is turned off.
- Connect phone to computer
- Copy ~/.android/adbkey.pub to phone's memory
- Go to Advanced > File manager
- Navigate to where adbkey.pub was copied to. I am using Redmi Note 4 and MTP connects to
/sdcard
on this device. - Copy
adbkey.pub
to/data/misc/adb/adb_keys
- Delete
adb_keys
in - Rename
adbkey.pub
toabd_keys
- Double check if content of
/data/misc/adb/adb_keys
on phone and~/.android/adbkey.pub
on computer are the same - Enjoy 😊️
It was a little annoying adventure for me to find where the adbkey.pub suppose to go. I am not immitated with having to do that thing manually. I was annoyed that this information isn't out there in Android documentations and requires reading answers from 2014 on stack overflow.