'Android Emulator "Allow USB Debugging" dialog close right after showing

I'm trying to debug with Android R in Pixel emulated devices w/ PlayServices but the "Allow USB Debugging" dialog instantly close right after showing, so I can't click in "Allow" to AS connect to the AVD. I went to Developer options in Android to switch off and on again the USB debugging, but again the dialog close imediatelly right after showing. I tried kill/star ADB and unistalling all AS/user configs/etc and reinstalling again but didn't solve. Anyone has a clue?



Solution 1:[1]

I had the same issue. I tried to click "Allow" in time, but it was too fast on my PC. However, I noticed that after a cold boot this popup pops and doesn't hide for some time (may be due to load lag), so I managed to click it this way.

If someone still has this problem and the goal is to upload some file or apk, better upload it to google drive and download it by link in the emulator.

Solution 2:[2]

Seems like this issue is related to your emulator's API version, after some testing I found that Pixel 4 API 30 have your problem, while others don't.

Versions

Another odd thing about the box is that it will ask you again for permission when you start a new session, even though I clicked the "always allow this device" button.

Solution 3:[3]

Wipe data and it will pop up and stay. Check the "always allow debugging on this device" box and you should be good to go.

Solution 4:[4]

  1. get your public key from ~/.android/adbkey.pub
  2. append it to /data/misc/adb/adb_keys of emulator (create it if not exist)
  3. restart emulator

then you should connect directly.

ref: How to solve ADB device unauthorized in Android ADB host device?

Solution 5:[5]

Try remove files adbkey and adbkey.pub in:

  • ~/.android/adbkey/ on Linux
  • %UserProfile%\.android on Windows
  • %ANDROID_SDK_HOME%\.android on Windows, if set
adb kill-server
adb devices

Restart the emulator after wiping its data. Then the permission for "USB Debugging" should be given and it should show up as debuggable device.

The problem should only appear with google_apis_playstore devices, see here. Reason I think is, that the key files are only copied by adb, if no other keys already exist on the emulator. So may deleting the files on the emulator may also work.

Solution 6:[6]

I solved this problem by following steps:

  1. Wipe emulator data
  2. Start emulator again

Above steps resulted in no dialog at all, weird, then I looked at the Android Studio, the emulator was already connected.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 UnholyRaven
Solution 2 Machavity
Solution 3 MandelMech
Solution 4 user2767141
Solution 5 Viktor Brešan
Solution 6 Dharman