What's Actually Happening

Android emulator fails to start. Emulator process crashes or hangs during launch, preventing app testing.

The Error You'll See

bash
Emulator: Process finished with exit code -1073741819

HAXM error:

bash
Emulator: emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.

Memory error:

bash
Emulator: Failed to allocate memory: 8192

GPU error:

bash
Emulator: GPU emulation is disabled
Emulator: Failed to initialize graphics

Why This Happens

  1. 1.HAXM not installed - Hardware acceleration missing
  2. 2.Virtualization disabled - VT-x/AMD-V disabled in BIOS
  3. 3.Insufficient RAM - Not enough memory for emulator
  4. 4.GPU driver issue - Graphics driver incompatible
  5. 5.AVD corruption - Android Virtual Device corrupted
  6. 6.SDK path issues - Incorrect SDK configuration

Step 1: Check System Requirements

```bash # Check if virtualization supported: # Windows: systeminfo | findstr /i "virtualization"

# macOS: sysctl -a | grep machdep.cpu.features | grep VMX

# Linux: egrep -c '(vmx|svm)' /proc/cpuinfo # Result > 0 means virtualization supported

# Check if enabled in BIOS: # Restart, enter BIOS, enable VT-x (Intel) or AMD-V

# Check available RAM: # Windows: wmic OS get TotalVisibleMemorySize /Value

# Linux: free -h

# macOS: sysctl hw.memsize

# Need at least 8GB RAM (16GB recommended) # Emulator needs 2-8GB depending on device config ```

Step 2: Install HAXM (Windows/macOS)

```bash # Windows: # Install via Android Studio: # SDK Manager -> SDK Tools -> Intel x86 Emulator Accelerator

# Or download directly: # https://github.com/intel/haxm/releases

# Run installer: # C:\Users\<user>\AppData\Local\Android\Sdk\extras\intel\Hardware_Accelerated_Execution_Manager\intelhaxm-android.exe

# Verify HAXM installed: sc query intelhaxm # Should show: STATE: 4 RUNNING

# macOS: # Install via SDK Manager or: brew install intel-haxm

# Or run: ~/Library/Android/sdk/extras/intel/Hardware_Accelerated_Execution_Manager/HAXM\ installation

# Verify: kextstat | grep intel

# Linux (use KVM): sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils sudo usermod -aG kvm $USER # Log out and back in ```

Step 3: Configure KVM (Linux)

```bash # Install KVM: sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils

# Add user to kvm group: sudo usermod -aG kvm $USER

# Log out and log back in

# Verify KVM: kvm-ok # Should show: "KVM acceleration can be used"

# Check KVM device: ls -la /dev/kvm # Should show your user has access

# Fix permissions if needed: sudo chmod 666 /dev/kvm

# Configure Android Studio to use KVM: # Already automatic if KVM installed ```

Step 4: Create New AVD

```bash # Via Android Studio: # Tools -> Device Manager -> Create Device

# Or via command line: avdmanager create avd \ --name "Pixel_API_33" \ --package "system-images;android-33;google_apis;x86_64" \ --device "pixel_6"

# List available devices: avdmanager list device

# List available system images: sdkmanager --list | grep system-images

# Install system image: sdkmanager "system-images;android-33;google_apis;x86_64"

# Create AVD with specific options: echo "no" | avdmanager create avd \ --name "TestDevice" \ --package "system-images;android-33;default;x86_64" \ --device "pixel_6"

# List AVDs: avdmanager list avd ```

Step 5: Configure Emulator Settings

```bash # Edit AVD config: # Location: ~/.android/avd/<avd_name>.avd/config.ini

# Key settings:

# Memory: hw.ramSize=4096 vm.heapSize=512

# CPU: hw.cpu.arch=x86_64 hw.cpu.ncore=4

# Graphics: hw.gpu.enabled=yes hw.gpu.mode=auto # or host, swiftshader

# HAXM: hw.audioInput=yes hw.audioOutput=yes

# Other useful settings: hw.keyboard=yes hw.lcd.density=480 hw.lcd.height=1920 hw.lcd.width=1080

# Save and restart emulator ```

Step 6: Fix GPU Issues

```bash # Check GPU mode: # In config.ini: hw.gpu.mode=auto

# Try different modes: # host - Use host GPU (fastest) # swiftshader - Software rendering (no GPU needed) # mesa - Software rendering (alternative) # angle - Windows only, DirectX-based

# Disable GPU: hw.gpu.enabled=no hw.gpu.mode=off

# Update graphics drivers: # Windows: Update via Device Manager or manufacturer # macOS: System updates # Linux: Update via package manager

# Check GPU support: emulator -verbose -avd <avd_name> 2>&1 | grep -i gpu

# For Nvidia: nvidia-smi

# For AMD: lspci | grep -i vga ```

Step 7: Cold Boot and Wipe Data

```bash # Cold boot emulator: # In Android Studio Device Manager: # Click dropdown next to Play -> Cold Boot Now

# Or via command line: emulator -avd <avd_name> -no-snapshot-load

# Wipe data: # In Device Manager: # Click dropdown -> Wipe Data

# Or delete AVD and recreate: rm -rf ~/.android/avd/<avd_name>.avd

# Clear emulator data: rm -rf ~/.android/avd/<avd_name>.avd/cache rm -rf ~/.android/avd/<avd_name>.avd/data

# Reset to factory: emulator -avd <avd_name> -wipe-data ```

Step 8: Check SDK Configuration

```bash # Check SDK path: echo $ANDROID_HOME echo $ANDROID_SDK_ROOT

# In Android Studio: # File -> Settings -> Appearance & Behavior -> System Settings -> Android SDK

# Verify SDK installed: ls $ANDROID_HOME

# Expected directories: # build-tools, emulator, platforms, system-images, tools

# Set environment variables: # ~/.bashrc or ~/.zshrc: export ANDROID_HOME=$HOME/Android/Sdk export ANDROID_SDK_ROOT=$ANDROID_HOME export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/platform-tools

# Windows: setx ANDROID_HOME "%LOCALAPPDATA%\Android\Sdk" setx PATH "%PATH%;%ANDROID_HOME%\emulator" setx PATH "%PATH%;%ANDROID_HOME%\platform-tools"

# Reload: source ~/.bashrc ```

Step 9: Run Emulator with Verbose Logging

```bash # Run with verbose output: emulator -verbose -avd <avd_name>

# Or more detailed: emulator -verbose -debug all -avd <avd_name> 2>&1 | tee emulator.log

# Check for specific issues: emulator -verbose -avd <avd_name> 2>&1 | grep -i error emulator -verbose -avd <avd_name> 2>&1 | grep -i haxm emulator -verbose -avd <avd_name> 2>&1 | grep -i gpu

# Run with specific options: emulator -avd <avd_name> \ -memory 4096 \ -cores 4 \ -gpu host \ -no-audio \ -no-boot-anim

# Use quick boot: emulator -avd <avd_name> -quickboot

# Run without snapshot: emulator -avd <avd_name> -no-snapshot ```

Step 10: Android Emulator Verification Script

```bash # Create verification script: cat << 'EOF' > ~/check-android-emulator.sh #!/bin/bash

echo "=== System Check ===" echo "OS: $(uname -a)" echo "RAM: $(free -h | grep Mem | awk '{print $2}')" echo "CPU: $(nproc) cores"

echo "" echo "=== Virtualization Check ===" if [ "$(uname)" = "Linux" ]; then kvm-ok ls -la /dev/kvm 2>/dev/null elif [ "$(uname)" = "Darwin" ]; then sysctl -a | grep -i "vmx|svm" | head -2 fi

echo "" echo "=== Android SDK ===" echo "ANDROID_HOME: $ANDROID_HOME" echo "SDK exists: $(test -d $ANDROID_HOME && echo 'Yes' || echo 'No')"

echo "" echo "=== Emulator Version ===" $ANDROID_HOME/emulator/emulator -version 2>/dev/null || echo "Emulator not found"

echo "" echo "=== Available AVDs ===" $ANDROID_HOME/emulator/emulator -list-avds 2>/dev/null || echo "No AVDs found"

echo "" echo "=== System Images ===" ls $ANDROID_HOME/system-images/ 2>/dev/null || echo "No system images"

echo "" echo "=== HAXM/KVM Status ===" if [ "$(uname)" = "Darwin" ]; then kextstat | grep -i intel elif [ "$(uname)" = "Linux" ]; then groups | grep kvm && echo "User in kvm group" || echo "User not in kvm group" fi

echo "" echo "=== Test Emulator Launch ===" echo "Run: emulator -verbose -avd <avd_name>"

echo "" echo "=== Recommendations ===" echo "1. Enable virtualization in BIOS" echo "2. Install HAXM (macOS/Windows) or KVM (Linux)" echo "3. Allocate at least 4GB RAM to emulator" echo "4. Update graphics drivers" echo "5. Create new AVD if corrupted" EOF

chmod +x ~/check-android-emulator.sh

# Usage: ~/check-android-emulator.sh ```

Android Emulator Checklist

CheckCommandExpected
Virtualization enabledBIOS/UEFIVT-x/AMD-V on
HAXM/KVM installedcheck scriptInstalled
Sufficient RAMfree -h8GB+ available
GPU driversupdateLatest version
AVD createdemulator -list-avdsAVD listed
SDK configuredecho $ANDROID_HOMEPath set

Verify the Fix

```bash # After fixing emulator issues

# 1. Check virtualization # BIOS shows VT-x enabled

# 2. Start emulator emulator -avd <avd_name> // Emulator window appears

# 3. Check boot // Android boots to home screen

# 4. Test app adb install app-debug.apk // App installs successfully

# 5. Check performance // Emulator responsive, no lag

# 6. Run tests ./gradlew connectedAndroidTest // Tests pass ```

  • [Fix Android Studio Build Failed](/articles/fix-android-studio-build-failed)
  • [Fix ADB Device Not Found](/articles/fix-adb-device-not-found)
  • [Fix Android App Not Installing](/articles/fix-android-app-not-installing)