<span>| in <ahref="https://murtezayesil.me/category/notes.html">Notes</a></span>
<span>| tags: <ahref="https://murtezayesil.me/tag/android.html">android</a><ahref="https://murtezayesil.me/tag/problem.html">problem</a><ahref="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span><span>| Day <strong>7</strong> of #100DaysToOffload</span>
<p>I like <ahref="https://github.com/Genymobile/scrcpy"title="scrcpy by Genymobile - GitHub">scrcpy</a>. It allows me to cast my phone to computer and use it ther thanks to cable technology (wifi works too). So, after hopping to <imgsrc="https://fosstodon.b-cdn.net/custom_emojis/images/000/025/123/static/a76f54a7dbcd8afd.png"width="15em"height="15em"> Pop_OS! I reinstalled adb and scrcpy.
But this time scrcpy didn't work. Instead it throw this error:<br>
<blockquotestyle="font-style: normal;">
<code>
adb: error: failed to get feature set: device unauthorized.<br>
This adb server's $ADB_VENDOR_KEYS is not set<br>
Try 'adb kill-server' if that seems wrong.<br>
Otherwise check for a confirmation dialog on your device.<br>
ERROR: "adb push" returned with value 1
</code>
</blockquote></p>
<h2>Easy way | Grant access using prompt on the phone</h2>
<p>After enabling <ahref="https://www.howtogeek.com/129728/how-to-access-the-developer-options-menu-and-enable-usb-debugging-on-android-4.2/">USB debugging in Developer options</a> connect phone to computer and run <code>scrcpy</code>. Phone should prompt you for granting access to computer. All you have to do is accept and connection will be granted 🎉️</p>
<hr>
<p>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 <ahref="https://stackoverflow.com/a/26309956">this answer on stack <strong>overflow</strong></a>. Which leads to a <ahref="https://android.googlesource.com/platform/system/core/+/d5fcafaf41f8ec90986c813f75ec78402096af2d">commit message for (new) adb authentication</a> implemented in 2012. This prompt copies ~/.android/adbkey.pub on computer, <code>$ADB_VENDOR_KEYS</code>, to <code>/data/misc/adb/adb_keys</code> file in phone's memory. since prompt isn't working for me I have to add that key manually 😕️</p>
<h2>Littler harder way | copy-paste using Termux + root</h2>
<p>Since <code>/data/misc/adb/adb_keys</code> file is offlimits for the user, we need root priviledges for this method.</p>
<ol>
<li>Copy ~/.android/adbkey.pub to phone's memory</li>
<li>Open Termux and install sudo ><code>pkg install tsu</code></li>
<li>Navigate to where file adbkey.pub is. I'm using Redmi Note 4 and its <code>/sdcard</code> directory is used for .<br>
File is at <code>/sdcard/adbkey.pub</code> in my case ><code>cd /sdcard</code></li>
<li>Copy <code>adbkey.pub</code> to <code>/data/misc/adb/adb_keys</code> with sudo priviledges ><code>sudo cp adbkey.pub /data/misc/adb/adb_keys</code></li>
<li>Double check if content of <code>/data/misc/adb/adb_keys</code> on phone and <code>~/.android/adbkey.pub</code> on computer are the same</li>
<p>This is the "no-root" hard method. You will still need root priviledges to edit <code>/data/misc/adb/adb_keys</code>. If your phone isn't rooted but has TWRP, GREAT. TWRP has root priviledges and a file manager.</p>
<ol>
<li>Boot into TWRP by holding Vol+ and Power keys while the phone is turned off.</li>
<li>Connect phone to computer</li>
<li>Copy ~/.android/adbkey.pub to phone's memory</li>
<li>Go to Advanced > File manager</li>
<li>Navigate to where adbkey.pub was copied to. I am using Redmi Note 4 and MTP connects to <code>/sdcard</code> on this device.</li>
<li>Copy <code>adbkey.pub</code> to <code>/data/misc/adb/adb_keys</code></li>
<li>Delete <code>adb_keys</code> in </li>
<li>Rename <code>adbkey.pub</code> to <code>abd_keys</code></li>
<li>Double check if content of <code>/data/misc/adb/adb_keys</code> on phone and <code>~/.android/adbkey.pub</code> on computer are the same</li>
<li>Enjoy 😊️</li>
</ol>
<p><imgalt="SCRCPY is casting Android phone's screen on to computer after manually copying computer's adbkey.pub file to phone's adb_keys file"src="images/scrcpy_casting_android_to_computer.png"title="scrcpy is finally working"></p>
<p>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 <strong>overflow</strong>.</p>
<p>Toot on <ahref="https://fosstodon.org/@murtezayesil/104558575376752243">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
<p>Powered by <ahref="http://getpelican.com/">Pelican</a>. Theme <ahref="https://github.com/blueicefield/pelican-blueidea/">blueidea</a>, inspired by the default theme.</p>
</footer><!-- /#contentinfo -->
<!-- IndieWeb Profile -->
<!-- ToDo : Make IndieWeb Profile auto generating according to site preferences -->
<!-- This profile is created by following https://kevq.uk/how-to-create-an-indieweb-profile/ blog post. Thanks to Kev Quirk -->
<sectionstyle="display: none;"class="h-card">
<!-- About me -->
<spanclass="p-name">Ali Murteza Yesil</span>
<spanclass="p-note">I'm a student, privacy advocate and SysAdmin wannabe. I was born in Turkey but I live abroad.</span>