
Complete guide on how to set up and run the Android emulator for Flutter development in Visual Studio Code. The whole step-by-step process help to configure more efficiently your development environment.
Table of Contents
Prerequisites
Before you go-ahead to set up the Android emulator in VS Code, the following should be installed:
- Visual Studio Code with extensions for Flutter and Dart
- Flutter SDK
- Android (for Android SDK and emulator)
- Java Development Kit (JDK)
Installing Android Studio and SDK
Notice!
Even if you intend to use VS Code as your main IDE, you need Android Studio to manage the Android SDK and emulator suite.
- Download and install Android Studio. Get it from the official website.
- Select Android SDK and Android Virtual Device during installation.
- Start Android Studio, and follow the basic, first-time setup wizard.
- Start SDK Manager (Tools > SDK Manager) and install the latest Android SDK.
Creating an Android Virtual Device (AVD)
To create a new Android emulator:
- Open your Android Studio.
- Just click or hover Tools > Device Manager.
- Finally, click "Create Virtual Device."
- Select any device definition (ex. Pixel 4)
- Choose a system image (recommended: API 30 or higher)
- Set AVD settings and finish.
Setting Up VS Code for Android Emulator
Configure VS Code to recognize and use the Android emulator:
- Open up Visual Studio Code.
- Install the "Flutter" extension if it hasn't been installed.
- Press Ctrl+Shift+Pon Windows/Linux or Cmd+Shift+P on macOS.
- Write "Flutter: Select Device" and hit Enter.
- You should see your created AVD in the device list.
Running the Android Emulator
There are multiple ways to launch the Android emulator in VS Code:
Method 1: Using VS Code Command Palette
- Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P
Method 2: Using Status Bar
- Look for "No Device" in the VS Code status bar
- Click on it to see available devices
- Select your Android emulator from the list
Troubleshooting Common Issues
Warning!
If the emulator fails to start, ensure your system's virtualization is enabled in BIOS settings.
Common Issues and Solutions:
Issue | Solution |
---|---|
Emulator not showing in device list | Restart VS Code and Flutter Doctor |
Slow emulator performance | Enable GPU acceleration in AVD settings |
HAXM not installed | Install Intel HAXM through Android Studio |
Best Practices
Follow these recommended steps to improve your development experience:
- Maintain the latest Android SDK and Flutter SDK
- Use a recent API level for better performance and feature support
- Configure your AVD by expanding RAM and storage provided
- Allow hardware acceleration to the possible extent
Sources:
flutter.dev/docs
developer.android.com/studio