Can launch, but not connect, to emulator in VS Code and Android Studio using flutter
Asked Answered
A

1

3

Short version, I can launch an android emulator from VS Code and Android Studio, but flutter won't connect to it when I do.

I'm installing Android Studio and VS Code fresh on a new laptop, along with flutter and dart. Latest versions of all those are installed at the time I'm writing this.

I had to disable Hyper-V in Windows (but kept it enabled in the BIOS) in order to install Intel's HAXM, but it is installed.

I downloaded an Android 9 'Pie' AVD image with Google Play included, and have created a Nexus 5X device with it.

I can launch the emulated device just fine from AVD manager, but neither VS Code nor Android Studio will connect to it. I've deleted the device and recreated it, wiped its data numerous times, done plenty of laptop reboots, and nothing doing.

Launching the device from within VS Code and AS works as expected, but neither will connect to the device. In VS Code I get the 'Emulator didn't connected within 60 seconds' message, even though the emulator starts as soon as I ask it to.

I've run adb kill-server and start-server numerous times, no difference.

When I run adb devices with the emulator running I get emulator-5554 unauthorized, so maybe there's a permissions thing going on somewhere?

I'm open to suggestions. Thanks.

[Edit] subsequent testing shows that I can connect to the emulator in VS Code and Android Studio if I use an Android 9 AVD without google play, and an Android 8.1 AVD both with Google Play or without. So it's the AVD with Android 9 and Google Play that's giving heartburn, and am not sure why?

Arly answered 14/3, 2019 at 20:58 Comment(1)
I always get the 60 second message when I first start emulator via VS Code. What I do is close the emulator and restart it using VS Code and it always connects 2nd time without fail.Capo
M
3

It sounds like ADB is not authorised to connect to the emulator. Try going into the developer settings on the device and revoking the USB debugging authorization, then restart the ADB server (adb kill-server && adb start-server) and see if the device pops up asking for you to approve connections from the PC (you may need to restart it).

Mata answered 15/3, 2019 at 12:37 Comment(4)
Hmm. I did as you suggested, and I see that dialog flash onscreen when the phone starts, but it then vanishes before I can say 'ok'. And I can't get it back up unless I reboot again, it doesn't appear in any recent items list, like you would see if you minimized another app such as Chrome. Bizarre...Arly
Strange - I presume it's not being auto-accepted because it's an emulator? If you run adb devices does it still show as unauthorized?Mata
Yes, it still shows as being unauthorized. It's really weird, how quickly that dialog shows and then sinks to the bottom, never to be seen again.Arly
I'm afraid I don't have any other ideas; this seems somewhat outside of Flutter and VS Code :/Mata

© 2022 - 2024 — McMap. All rights reserved.