Android Emulator
Android Emulator Create and configure Android emulators for development and testing
Android Tools Quest #17 Intermediate

Android Emulator

Create and configure Android emulators for development and testing

androidemulatormobiletesting
Download as:

What is Android Emulator?

The Android Emulator simulates Android devices on your computer. It allows you to develop and test Android apps without physical devices.

Emulators are essential for Appium testing on Android when physical devices aren’t available.

Prerequisites

Creating an Emulator via Android Studio

  1. Open Android Studio
  2. Click More Actions > Virtual Device Manager
  3. Click Create Device
  4. Select a device definition (e.g., Pixel 7)
  5. Select a system image (download if needed)
  6. Configure AVD options and click Finish

Creating an Emulator via Command Line

List Available System Images

sdkmanager --list | grep "system-images"

Download a System Image

sdkmanager "system-images;android-34;google_apis;arm64-v8a"

Create an AVD (Android Virtual Device)

avdmanager create avd \
  -n Pixel7 \
  -k "system-images;android-34;google_apis;arm64-v8a" \
  -d "pixel_7"

Options:

  • -n - AVD name
  • -k - System image package
  • -d - Device definition

List Device Definitions

avdmanager list device

List Created AVDs

avdmanager list avd
# or
emulator -list-avds

Starting an Emulator

From Command Line

emulator -avd Pixel7

With Options

# Start with wiped data
emulator -avd Pixel7 -wipe-data

# Start headless (no GUI)
emulator -avd Pixel7 -no-window

# Start with specific memory
emulator -avd Pixel7 -memory 4096

# Cold boot (skip snapshot)
emulator -avd Pixel7 -no-snapshot-load

Managing Emulators

Delete an AVD

avdmanager delete avd -n Pixel7

Rename an AVD

avdmanager move avd -n OldName -r NewName

Useful ADB Commands

For more ADB commands, see the ADB (Android Debug Bridge) android tools guide.

List Connected Devices

adb devices

Shell into Emulator

adb shell

Install an APK

adb install /path/to/app.apk

Uninstall an App

adb uninstall com.example.app

Take a Screenshot

adb shell screencap /sdcard/screen.png
adb pull /sdcard/screen.png

Record Screen

adb shell screenrecord /sdcard/recording.mp4
# Press Ctrl+C to stop
adb pull /sdcard/recording.mp4

View Logs

adb logcat

Restart ADB Server

adb kill-server
adb start-server

Performance Tips

Use Hardware Acceleration

Ensure Hypervisor Framework (HVF) is enabled on macOS. HVF is available on macOS 10.10+ and is the only supported accelerator for the Android Emulator on macOS. HAXM was removed from Android Emulator 36.2.x and is not supported on macOS 11+.

Verify acceleration on macOS:

$ANDROID_HOME/emulator/emulator -accel-check

For testing, configure your AVD with:

  • RAM: 2048 MB or more
  • VM Heap: 512 MB
  • Internal Storage: 2048 MB
  • SD Card: 512 MB

Quick Boot

Enable Quick Boot in AVD settings to save emulator state and reduce startup time.

Tips & Scripts

Launch an AVD with a Picker (macOS)

This AppleScript prompts you to select from your available AVDs and launches it. Save it as an app via Script Editor or Automator for one-click access:

set avds to paragraphs of (do shell script "~/Library/Android/sdk/emulator/emulator -list-avds")
if (count of avds) is 0 then
	display dialog "No AVDs found. Create one in Android Studio first." buttons {"OK"} default button "OK"
	return
end if
set avd to (choose from list avds with prompt "Select an AVD to start" OK button name {"Start"} cancel button name {"Cancel"})
if avd is false then return
set avdSelected to item 1 of avd
do shell script "~/Library/Android/sdk/emulator/emulator -avd " & quoted form of avdSelected & " -no-boot-anim > /dev/null 2>&1 &"

If your Android SDK is installed elsewhere, update the path to the emulator binary. Find it with which emulator or check $ANDROID_HOME/emulator/.

Wipe AVD Data with a Picker

This script lists your AVDs and lets you select one to wipe — useful when an emulator gets into a bad state and you want a clean reset:

#!/usr/bin/env bash
mapfile -t avd_list < <(emulator -list-avds)

if [[ ${#avd_list[@]} -eq 0 ]]; then
  echo "No AVDs found. Create one in Android Studio first."
  exit 1
fi

select avd in "${avd_list[@]}"; do
  if [[ -n "$avd" ]]; then
    echo "Wiping data for AVD: $avd"
    emulator -avd "$avd" -wipe-data
    break
  else
    echo "No AVD selected. Exiting..."
    exit
  fi
done

Disable Emulator Audio

Running an emulator with audio enabled can distort or degrade audio playback on the host machine — music, calls, and other audio become garbled while the emulator is running. This script disables audio input and output for all AVDs:

#!/usr/bin/env bash
find ~/.android/avd -name "config.ini" | while read -r config; do
  # Remove existing audio config keys
  grep -v '^hw\.audioInput\|^hw\.audioOutput\|^avd\.audio\|^audio\.device\|^hw\.audio' "$config" > "$config.tmp"
  mv "$config.tmp" "$config"
  # Disable audio
  echo "hw.audioInput = no" >> "$config"
  echo "hw.audioOutput = no" >> "$config"
done

Restart any running emulators for the change to take effect.

Troubleshooting

”PANIC: Missing emulator engine program”

Ensure emulator is in PATH:

export PATH=$PATH:$ANDROID_HOME/emulator

Emulator is Slow

  1. Enable hardware acceleration
  2. Prefer 64-bit images (x86_64 on Intel machines, arm64 on Apple Silicon) rather than 32-bit x86 images
  3. Allocate more RAM
  4. Use SSD storage

”Device unauthorized”

  1. Revoke USB debugging authorizations in Developer options
  2. Restart ADB: adb kill-server && adb start-server
  3. Reconnect device

Reset to Factory

emulator -avd Pixel7 -wipe-data

Resources

🔗
Android Emulator Documentation developer.android.com

Official documentation for the Android Emulator

🔗
AVD Manager Documentation developer.android.com

Learn how to create and manage Android Virtual Devices

🔗
Emulator Command Line Options developer.android.com

Complete reference for emulator command-line flags