$ADB_VENDOR_KEYS is not set

Categories:

Story

I like scrcpy. It allows me to cast my phone to computer and use it there thanks to cable technology (Wi-Fi works too). So, after hoping to Pop_OS! I reinstalled adb and scrcpy. But this time scrcpy didn’t work. Instead, it threw 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 work 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 on Termux as root

Since /data/misc/adb/adb_keys file is off-limits for the user. We need root privileges for this method.

  1. Copy ~/.android/adbkey.pub to phone’s memory
  2. Open Termux and install sudo > pkg install tsu
  3. Navigate to where file adbkey.pub is. I’m using a Redmi Note 4 and its /sdcard directory is used for .
    File is at /sdcard/adbkey.pub, in my case, > cd /sdcard
  4. Copy adbkey.pub to /data/misc/adb/adb_keys with sudo privileges > sudo cp adbkey.pub /data/misc/adb/adb_keys
  5. Double check if content of /data/misc/adb/adb_keys on phone and ~/.android/adbkey.pub on computer are the same
  6. Enjoy ๐Ÿ˜Š๏ธ
Video of terminal on an Android phone showing what was discussed above.

Hard way: copy-paste using TWRP

This is the “no-root” hard method. You will still need root privileges to edit /data/misc/adb/adb_keys. If your phone isn’t rooted but has TWRP, GREAT. TWRP has root privileges and a file manager.

  1. Boot into TWRP by holding Vol+ and Power keys while the phone is turned off.
  2. Connect phone to computer.
  3. Copy ~/.android/adbkey.pub to phone’s memory
  4. Go to Advanced > File manager.
  5. Navigate to where adbkey.pub was copied to. I am using Redmi Note 4 and MTP connects to /sdcard on this device.
  6. Copy adbkey.pub to /data/misc/adb/adb_keys.
  7. Delete adb_keys as the old one wasn’t working.
  8. Rename adbkey.pub to abd_keys.
  9. Double check if content of /data/misc/adb/adb_keys on phone and ~/.android/adbkey.pub on computer are the same.
  10. Enjoy ๐Ÿ˜Š๏ธ
A screenshot showing successful scrcpy connection between the Android phone and the computer.

It was a little annoying adventure for me to find where the adbkey.pub was supposed to go. I am not intimidated with having to do that this manually. I was annoyed that this information isn’t out there in Android documentations and requires reading answers from 2014 on stack overflow.

I hope this guide was helpful to you ๐Ÿ˜Š๏ธ

Day 7 of #100DaysToOffload


Comments

Toot on this thread to comment. This blog is a static site. Comments won’t appear here.


Replies and Reactions