Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tahir-hassan/a9dfc52f6aabc4b9281dafaae69ac68d to your computer and use it in GitHub Desktop.
Save tahir-hassan/a9dfc52f6aabc4b9281dafaae69ac68d to your computer and use it in GitHub Desktop.
Flutter - Emulators not appearing in Visual Studio Code

Problem

When opening a Flutter project in VSCode, in the list of devices you can debug against, you don't see the list of emulators that are listed in Android Studio.

Diagnosis

First run:

avdmanager list avd

This should give a list of virtual devices which are available. For example:

    Name: flutter_emulator
  Device: pixel (Google)
    Path: C:\Users\you\AppData\Local\.android\avd\flutter_emulator.avd
  Target: Google Play (Google Inc.)
          Based on: Android API 35 Tag/ABI: google_apis_playstore/x86_64
  Sdcard: 512 MB

Next try:

emulator -avd flutter_emulator

Replace flutter_emulator above with the name of your emulator. You may get an error:

ERROR    | Unknown AVD name [flutter_emulator], use -list-avds to see valid list.
ERROR    | HOME is defined but there is no file flutter_emulator.ini in $HOME\.android\avd
ERROR    | (Note: Directories are searched in the order $ANDROID_AVD_HOME, $ANDROID_SDK_HOME\avd and $HOME\.android\avd)

Solution

Set a user environment variable ANDROID_AVD_HOME to the path above given by avdmanager. Using the above example, would set it to C:\Users\you\AppData\Local\.android\avd.

You can open the user environment variable screen by using Start, Run, rundll32 sysdm.cpl,EditEnvironmentVariables.

Now running the emulator command above should work. You will see it in the list of available devices in VSCode (you don't need to start it, as it is already started).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment