Android Emulator "Allow USB Debugging" dialog close right after showing
Asked Answered
B

9

26

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?

Bedpan answered 16/9, 2020 at 14:50 Comment(2)
Are you using a real device or emulator?Punctuality
AS emulator, up to date.Harbird
U
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.

Ufa answered 2/12, 2020 at 23:42 Comment(1)
Actually this is the only way I managed to run the apk, copying and installing it, the AVD doesn't connect to the Android Studio and after 300 seconds give a message that waited and wasn't able to connect.Harbird
A
9

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.

Alcove answered 10/3, 2021 at 0:51 Comment(0)
U
9

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.

Uniform answered 22/6, 2021 at 10:3 Comment(4)
Pixel 3a API 30 also has the same problem.Highflier
Pixel 3 API 30 also has the same problem.Weismann
I stick to pixel 2.Uniform
API lvl 30 has problems. Use anotherBoelter
S
6

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.

Syncom answered 9/1, 2022 at 22:15 Comment(3)
It didn't help in my case. Dialog is still disappearing before I have a chance to click on it.Weismann
@ViktorBrešan did you change the ANDROID_SDK_HOME or ANDROID_PREFS_ROOT variable? Make sure any old keys are deleted in any possible .android directory. If so, there shouldn't come up a dialog at all, the keys are then copied automatically to your device and you should be able to debug without confirming :)Syncom
It wasn't problem with folders, I have slightly 'corrected' your answer.Weismann
L
5

This problem occurs with Pixel emulators on API level 30, so choosing 31 instead will solve the issue.

Lovins answered 2/9, 2022 at 9:21 Comment(1)
True!!, API level 30 has problem, at 31 "Allow usb debugging" dialog box easily popped up.Boelter
H
3
  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?

Hildagarde answered 24/12, 2020 at 12:43 Comment(2)
Unfortunately nothing worked, not even uninstalling Android Studio, the only way to work is to select a non-PlayServices from the AVD list.Harbird
i experience the same as @MaurícioLima . also, how would you put the key on the device if you cannot connect to it..?Transport
U
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.

Ufa answered 2/12, 2020 at 23:42 Comment(1)
Actually this is the only way I managed to run the apk, copying and installing it, the AVD doesn't connect to the Android Studio and after 300 seconds give a message that waited and wasn't able to connect.Harbird
D
1

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.

Diathermy answered 17/2, 2022 at 5:59 Comment(1)
Same situation for me, after wipe it was already authorized/connectedExcepting
E
0

After some experiments I found that x86 apis were showing this error so simply switching to x86_64 apis solved the problem :

enter image description here

Eudemonia answered 9/9, 2022 at 20:40 Comment(0)
H
0

In my case, it was because I had enabled an accessibility app. At least, after trying various things (turning on/off developer mode, USB debugging, etc.;, rebooting and so on), I disabled that accessibility service, and voila, the "Allow USB debugging" was back to normal!

Heloise answered 8/3, 2023 at 17:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.