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

4,095

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).

Share:
4,095
larryq
Author by

larryq

Updated on December 10, 2022

Comments

  • larryq
    larryq over 1 year

    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?

  • larryq
    larryq over 5 years
    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...
  • Danny Tuppeny
    Danny Tuppeny over 5 years
    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?
  • larryq
    larryq over 5 years
    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.
  • Danny Tuppeny
    Danny Tuppeny over 5 years
    I'm afraid I don't have any other ideas; this seems somewhat outside of Flutter and VS Code :/