androidandroid-studioadbrsa-key-fingerprint

Physical devices not working in Android Studio: Multiple RSA key fingerprints but only one adbkey.pub


I develop using a pixel 2xl and a macbook pro. I have a problem that is bugging me since months now. When i connect the phone to the pc i get the classic popup asking to "Allow usb debugging? The computer's RSA key fingerprint is: xx:xx:xx:xx:xx:.....xx:xx" and then the box with "Always allow from this computer" and the two buttons "cancel" and "allow". The problem is that i get two different key fingerprints, one doesn't work with android studio and I have to click "cancel" and switch on and off the "Usb debugging" switch until i finally get the right key. I tried to uninstall Android Studio and all the related folders, following the How to completely uninstall Android Studio on Mac? and when nothing was installed on the pc i still got the rogue key fingerprint on the message. I tried to delete the only adbkey.pub and only the good key fingerprint changed. I tried to "Revoke Usb debugging authorizations" on the device but nothing. I run a "ps aux | grep adb" and no adb was running when i still got the rogue key fingerprint. No other adbkey files seem present on my pc too.

Where this rogue key fingerprint comes from? how to get rid of it? This is seriously making my developing days a big big pain. Thanks


Solution

  • I think i found finally the solution:

    IMPORTANT: to diagnose the problem was essential to "Revoke USB debugging authorisations" from the developer options on the device, and never check the "Always allow from this computer". If you check that option instead, the popup will not appear and you could find yourself connected but with a wrong RSA key. In android studio you will see your device connected on the usb list but not as android device. This will look as a problem of the connection (cable, etc) but instead the connection mechanism is working, it's just that Android Studio will not be able to use it due to wrong fingerprint.

    The rogue RSA key fingerprint was triggered by chrome://inspect with Discover USB devices checked. This option allows you to see the Android device without adb, so it probably mimics behaviour of the adb with its own certificate. This is a big big mistake from chrome developers, because it interferes with the Android Studio behaviour! It doesn't store the certificate it uses on ~/.Android folder in a adbkey.pub so it makes very difficult to discover the problem. I used chrome inspect to see the database of my app using facebook stetho. I had always a tab opened and that made my last two months of coding like hell! Hope this helps someone.