How to add Android emulators to VS code?

Viewed 6698

When I use flutter run command it shows the following message:

Multiple devices found:
Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.146
Edge (web)   • edge   • web-javascript • Microsoft Edge 86.0.622.51
[1]: Chrome (chrome)
[2]: Edge (edge)
Please choose one (To quit, press "q/Q"):

Also this is the result of flutter emulators command:

3 available emulators:

Nexus_5x       • Nexus_5x       • Google • android
Pixel_2_API_29 • Pixel 2 API 29 • Google • android
pixel_xl       • pixel_xl       • Google • android

To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.

You can find more information on managing emulators at the links below:
  https://developer.android.com/studio/run/managing-avds
  https://developer.android.com/studio/command-line/avdmanager

Is it possible to add Android emulators to the list of flutter run command beside chrome and edge browsers?

3 Answers

You should:

  • Retrieve the list of the available emulators
flutter emulators
  • Launch the emulator
flutter emulators --launch Nexus_5x

Then when you run flutter run you should see your new android emulator.

The flutter devices command shows "available devices". Emulators that have not been started are not "available" until they've been started.

If you're using VS Code, you may find it better to use the built-in device management and debugging rather than using the terminal. In the status bar in the bottom right corner it should show your "active device" and if you click on it, it will let you switch to another device. That list shows emulators even if they're not started, and selecting one will automatically start it.

Device/Emulator list

  • Download Android SDK and make initial setup.

  • Relaunch VSCode and clean the project:

    flutter clean
    
  • if this didn't help, try to update licences:

    flutter doctor --android-licenses
    
Related