Scientyfic World

Write Structured content faster — Get your copy of DITA Decoded today.

How to set up Android Emulator in VS Code on MacOs?

Sharing is Caring
android emulator in vs code

Android Studio consumes significant system resources and storage space. The complete IDE package requires over 4GB of disk space and substantial RAM allocation. Many developers prefer lightweight alternatives for Android app testing and debugging.

VS Code provides an efficient development environment for Android projects. It allows you to achieve the same emulator functionality without the overhead of Android Studio’s full IDE. This approach benefits developers working with React Native, Flutter, Cordova, or any framework requiring Android device testing.

The Android SDK Command-Line Tools package offers all essential components for emulator creation and management. You gain direct control over SDK components, faster installation, and reduced system resource consumption.

This setup method works for all MacBook models, including Apple Silicon (M1/M2/M3) and Intel processors. The configuration supports both native Android development and cross-platform frameworks.

This guide covers the complete setup process for running Android emulators directly from VS Code on your MacBook without installing Android Studio.

Prerequisites

You need three components before starting:

Java Development Kit (JDK)
Install the OpenJDK distribution called Azul Zulu using Homebrew. This distribution offers JDKs for both Apple Silicon and Intel Macs.

# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Java JDK
brew install --cask zulu17
Bash

Verify Java installation:

java -version

You should see Java 17 or higher output.

Watchman (for file watching)

brew install watchman

Step 1: Download Android SDK Command-Line Tools

The Android SDK Command-Line Tools package, located in cmdline-tools, replaces the SDK Tools package, located in tools. With the new package, you can select the version of the command line tools you want to install, and you can install multiple versions at a time.

Download the command-line tools from the official Android Developer website:

  1. Visit Android Studio Command Line Tools
  2. Download “Command line tools only” for Mac
  3. The downloaded file will be named commandlinetools-mac-XXXXXXX_latest.zip

Step 2: Create Android SDK Directory Structure

Create the proper directory structure that Android tooling expects:

# Create SDK directory
mkdir -p ~/Library/Android/sdk/cmdline-tools

# Extract downloaded tools
cd ~/Downloads
unzip commandlinetools-mac-*_latest.zip

# Move tools to correct location
mv cmdline-tools ~/Library/Android/sdk/cmdline-tools/latest
Bash

Why this specific structure? Move the unzipped cmdline-tools directory into a new directory of your choice, such as android_sdk. This new directory is your Android SDK directory. In the unzipped cmdline-tools directory, create a sub-directory called latest.

Step 3: Configure Environment Variables

Add Android SDK paths to your shell profile. macOS Monterey and later use Zsh by default:

# Open your shell profile
nano ~/.zshrc

# Add these lines
export ANDROID_HOME="$HOME/Library/Android/sdk"
export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk"
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$PATH"
export PATH="$ANDROID_HOME/platform-tools:$PATH"
export PATH="$ANDROID_HOME/emulator:$PATH"
export PATH="$ANDROID_HOME/tools:$PATH"
export PATH="$ANDROID_HOME/tools/bin:$PATH"

# Set Java home
export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home"
Bash

Apply changes:

source ~/.zshrc

Verify environment setup:

echo $ANDROID_HOME
# Should output: /Users/[username]/Library/Android/sdk

Step 4: Install Required Android SDK Components

You can use the sdkmanager to list installed and available packages, install packages, and update packages.

Create the repositories configuration file first:

touch ~/.android/repositories.cfg

Accept all Android SDK licenses:

yes | sdkmanager --licenses

Install core Android SDK components:

# Platform tools (includes ADB)
sdkmanager "platform-tools"

# Latest Android platform
sdkmanager "platforms;android-34"

# Build tools
sdkmanager "build-tools;34.0.0"

# Emulator
sdkmanager "emulator"

# System images for emulator (choose based on your Mac)
# For Apple Silicon Macs (M1/M2/M3):
sdkmanager "system-images;android-34;google_apis;arm64-v8a"

# For Intel Macs:
sdkmanager "system-images;android-34;google_apis;x86_64"
Bash

Verify installation:

sdkmanager --list_installed

Do you see all the components listed? If any are missing, reinstall them using the commands above.

Step 5: Create Android Virtual Device (AVD)

Each instance of the Android Emulator uses an Android virtual device (AVD) to specify the Android version and hardware characteristics of the simulated device.

List available device definitions:

avdmanager list device

Create your first AVD:

# For Apple Silicon Macs
avdmanager create avd -n "MyEmulator" -k "system-images;android-34;google_apis;arm64-v8a" -d "pixel_7"

# For Intel Macs  
avdmanager create avd -n "MyEmulator" -k "system-images;android-34;google_apis;x86_64" -d "pixel_7"
Bash

Verify AVD creation:

avdmanager list avd

The output should show your newly created virtual device.

Step 6: Launch the Emulator

Start your emulator from command line:

emulator -avd MyEmulator

The emulator window should open. Initial boot takes 2-3 minutes.

Test ADB connection:

adb devices

You should see your emulator listed as a connected device.

Step 7: Configure VS Code Integration

Install VS Code extensions for Android development:

Required Extensions:

  1. Android iOS Emulator (DiemasMichiels.emulate)
  2. Android Emulator Launcher (Dannark.AndroidLauncher)
  3. Android Full Support (AntonyDalmiere.android-support)

Install via VS Code:

  1. Open VS Code
  2. Press Cmd+Shift+X to open Extensions
  3. Search for each extension by name
  4. Click Install

Configure emulator path in VS Code:

  1. Open VS Code Settings (Cmd+,)
  2. Search for “emulator”
  3. Give Emulator path as same as mentioned in the image
  4. Set emulator path to: /Users/[username]/Library/Android/sdk/emulator/emulator

Step 8: Launch Emulator from VS Code

Press Ctrl+Shift+P to open the Command Palette and type “Run Android Emulator”. Select the emulator you want to use from the list.

Method 1: Command Palette

  1. Press Cmd+Shift+P
  2. Type “Run Android Emulator”
  3. Select your emulator from the list

Method 2: Extension Button Now you are sorted out and you will get the mobile icon on the top right as you click that icon you will get the list of available virtual devices.

Click the mobile device icon in VS Code’s top toolbar to see available emulators.

Advanced Configuration

Create multiple AVDs for different testing scenarios:

# Tablet emulator
avdmanager create avd -n "TabletEmulator" -k "system-images;android-34;google_apis;arm64-v8a" -d "10.1in WXGA (Tablet)"

# Different API level
sdkmanager "system-images;android-33;google_apis;arm64-v8a"
avdmanager create avd -n "API33Emulator" -k "system-images;android-33;google_apis;arm64-v8a" -d "pixel_6"
Bash

Performance optimization:

# Launch with performance flags
emulator -avd MyEmulator -no-snapshot-load -no-snapshot-save -gpu host
Bash

Troubleshooting Common Issues

Issue: “emulator: ERROR: No AVD specified”

  • Solution: Always specify AVD name: emulator -avd YourAVDName

Issue: “HAXM is not installed”

  • Solution: Apple Silicon Macs don’t need HAXM. Intel Macs should install it:
sdkmanager "extras;intel;Hardware_Accelerated_Execution_Manager"

Issue: “Command not found: emulator”

  • Solution: Verify PATH contains emulator directory:
echo $PATH | grep emulator

Issue: Slow emulator performance

  • Enable hardware acceleration in emulator settings
  • Allocate more RAM to the AVD (edit via avdmanager)
  • Close unnecessary applications

Are you experiencing any other issues? The Android emulator logs provide detailed debugging information:

emulator -avd MyEmulator -verbose

Verification Checklist

Confirm your setup works correctly:

  • [ ] Java JDK installed and accessible
  • [ ] Android SDK command-line tools downloaded and extracted
  • [ ] Environment variables configured in shell profile
  • [ ] Required SDK components installed via sdkmanager
  • [ ] At least one AVD created successfully
  • [ ] Emulator launches from command line
  • [ ] ADB recognizes running emulator
  • [ ] VS Code extensions installed and configured
  • [ ] Emulator launches from VS Code interface

Your Android emulator setup is now complete. You can develop and test Android applications using VS Code without installing Android Studio.

Next Steps

Consider exploring these additional development tools:

  • React Native CLI for cross-platform development
  • Flutter SDK for Google’s UI toolkit
  • Gradle for Android project building

Ready to start building your first Android application in this streamlined development environment?

Conclusion

You have successfully configured a complete Android development environment without Android Studio. This streamlined setup provides several advantages over the traditional approach.

Your system now consumes significantly less disk space and memory. The command-line tools approach eliminates Android Studio’s resource overhead while maintaining full emulator functionality. You gained precise control over SDK component versions and installation locations.

The VS Code integration enables seamless emulator management directly from your code editor. You can launch multiple emulator instances, switch between different Android API levels, and test applications across various device configurations.

This configuration supports multiple development frameworks. Whether you build native Android apps, React Native applications, Flutter projects, or Cordova applications, your emulator environment handles all testing requirements.

Regular maintenance keeps your setup current. Update SDK components using the sdkmanager commands. Create additional AVDs for new Android versions as they release. Monitor emulator performance and adjust configuration parameters based on your development needs.

You established a professional Android development workflow optimised for efficiency and productivity.

Frequently Asked Questions

What are the minimum system requirements for running Android emulator on macOS?

Your MacBook needs at least 8GB RAM and 10GB free disk space. Apple Silicon Macs (M1/M2/M3) provide better emulator performance than Intel Macs. The emulator requires hardware acceleration support, which all modern MacBooks provide.
SSD storage significantly improves emulator boot times compared to traditional hard drives. macOS 12.0 (Monterey) or later offers optimal compatibility with current Android SDK versions.

Can I use this setup for React Native and Flutter development?

Yes, this emulator configuration works with all cross-platform frameworks. React Native CLI recognizes the emulator automatically when you run npx react-native run-android. Flutter SDK detects the emulator through flutter devices command.
Both frameworks use the same ADB connection and AVD system. You can test React Native and Flutter applications without any additional configuration changes.

How does this approach compare to using Android Studio’s built-in emulator?

The command-line approach consumes 75% less disk space and uses significantly less RAM. Android Studio’s emulator includes additional debugging tools and UI conveniences, but core emulator functionality remains identical.
VS Code extensions provide most debugging features available in Android Studio. You trade some advanced debugging capabilities for improved system performance and faster startup times.

Should I use ARM64 or x86_64 system images on Apple Silicon Macs?

Always use ARM64 system images on Apple Silicon Macs. ARM64 images run natively without translation, providing superior performance. x86_64 images require translation layers that slow emulator execution significantly.
Intel Macs should use x86_64 system images for optimal performance. The system image architecture must match your Mac’s processor architecture for best results.

How do I update Android SDK components and create new emulators?

Update all SDK components using sdkmanager –update command. Install new Android API levels with sdkmanager “platforms;android-XX” where XX represents the API level number.
Create additional emulators using avdmanager create avd command with different device definitions and API levels. List available system images with sdkmanager –list to see installation options for new Android versions.
Regular updates maintain compatibility with latest Android features and security patches.

On This page

Subscribe to Tech-Break for exclusive monthly insights on tech and business that drive success!

Snehasish Konger profile photo

Hey there — I’m Snehasish. I write to make complex tech feel simple, useful, and accessible. From coding how-to guides to detailed breakdowns of tools and systems, this blog is where I share what I learn, build, and break — so you don’t have to.

Related Posts

Generate Summary
avatar of joe
Ask Joe