Android Emulator
Command Line
Android Development
Emulator Launch
Android Debugging

How do I launch the Android emulator from the command line?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Launching the Android emulator from the command line is useful for automation, CI jobs, and plain day-to-day development when you do not want to open Android Studio just to boot a device. The workflow is simple once three pieces are in place: the SDK paths, an AVD definition, and the emulator command itself.

The important detail is that adb does not launch an emulator. adb talks to devices after they exist. Creating and starting the emulator is handled by avdmanager and emulator.

Make Sure the SDK Tools Are on Your Path

The modern SDK layout usually needs these directories available:

bash
1export ANDROID_SDK_ROOT="$HOME/Android/Sdk"
2export PATH="$PATH:$ANDROID_SDK_ROOT/emulator"
3export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools"
4export PATH="$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin"

Then verify the tools:

bash
emulator -version
adb version
avdmanager list avd

If emulator or avdmanager is not found, the path is still wrong or the command-line tools are not installed.

List Existing Virtual Devices

If you already created an emulator device in Android Studio or with avdmanager, list it like this:

bash
emulator -list-avds

That prints names such as:

text
Pixel_8_API_34
Tablet_API_33

Once you have a valid AVD name, launch it with:

bash
emulator -avd Pixel_8_API_34

That is the core answer.

Create an AVD From the Command Line

If no virtual device exists yet, install a system image and create one. First, install the package:

bash
sdkmanager "platform-tools" \
  "emulator" \
  "system-images;android-34;google_apis;x86_64"

Then create the AVD:

bash
1avdmanager create avd \
2  -n Pixel_8_API_34 \
3  -k "system-images;android-34;google_apis;x86_64" \
4  --device "pixel_8"

Now boot it:

bash
emulator -avd Pixel_8_API_34

If the device name is not accepted, run avdmanager list device and choose one from the installed definitions.

Useful Startup Flags

The emulator command supports many options. A few are especially practical:

bash
emulator -avd Pixel_8_API_34 -no-boot-anim
emulator -avd Pixel_8_API_34 -no-window -no-audio
emulator -avd Pixel_8_API_34 -wipe-data

Typical uses:

  • '-no-boot-anim speeds up startup during test runs'
  • '-no-window is useful in headless environments'
  • '-wipe-data resets the emulator to a clean state'

Be careful with -wipe-data because it erases the device state for that AVD.

Wait Until the Emulator Is Actually Ready

A common mistake is starting the emulator and immediately trying to install an APK. The process may exist, but Android might still be booting. Use adb to wait:

bash
1adb wait-for-device
2
3while [ "$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" != "1" ]; do
4  sleep 1
5done
6
7echo "Emulator booted"

After that, commands such as installation or instrumentation are much more reliable:

bash
adb install app-debug.apk
adb shell am start -n com.example/.MainActivity

Multiple Emulators and Device Selection

If more than one emulator or phone is connected, adb needs a target serial. List devices first:

bash
adb devices

Then address a specific emulator:

bash
adb -s emulator-5554 install app-debug.apk

This matters in CI or on developer machines with a physical phone connected.

Common Pitfalls

The most common mistake is using adb as if it creates emulators. It does not. Use emulator -avd ... to boot the device and adb only after it appears.

Another common issue is relying on older path examples that include legacy tools directories. On modern SDK setups, cmdline-tools/latest/bin is the important path for avdmanager.

Teams also start tests too early. A visible emulator window does not guarantee that Android finished booting. Always wait for sys.boot_completed or an equivalent readiness check.

Finally, when emulator -list-avds shows nothing, the problem is not the launch command. It means no AVD has been created yet under the current SDK and user profile.

Summary

  • Use emulator -list-avds to discover available virtual devices.
  • Launch one with emulator -avd AVD_NAME.
  • Create new devices with sdkmanager and avdmanager when needed.
  • Use adb after boot to install apps and run commands.
  • For automation, wait until sys.boot_completed reports 1 before continuing.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.