avdmanager create avd: Create an Emulator AVD in CI
avdmanager create avd defines a virtual device named by -n from a system-image package given with -k, ready for the emulator to launch.
Before you can boot a headless emulator you need an AVD. avdmanager builds one from an installed system image; the two gotchas are installing that image first and answering the hardware-profile prompt.
What it does
avdmanager create avd writes an AVD configuration (config.ini and userdata images) under $ANDROID_AVD_HOME or ~/.android/avd. -k names the system image package (which must already be installed via sdkmanager), -d optionally sets a hardware device profile, and --force overwrites an existing AVD of the same name.
Common usage
sdkmanager "system-images;android-34;google_apis;x86_64"
echo "no" | avdmanager create avd \
-n test_avd \
-k "system-images;android-34;google_apis;x86_64" \
-d pixel_6 --forceOptions
| Flag | What it does |
|---|---|
| -n <name> | Name of the AVD (used by emulator -avd) |
| -k "<system-image;path>" | System image package to base the AVD on |
| -d <device> | Hardware profile, e.g. pixel_6 (see avdmanager list device) |
| -c <size> | Size of the SD card, e.g. 512M |
| --force | Overwrite an existing AVD with the same name |
| --abi <abi> | Pick the ABI when the image has several |
In CI
Use x86_64 (not arm64) system images on Intel/AMD runners so the emulator runs with hardware acceleration; arm images fall back to slow full emulation. Pipe echo "no" into the command to decline the "create a custom hardware profile" prompt so it stays non-interactive.
Common errors in CI
"Error: Package path is not valid. Valid system image paths are:" means the -k image is not installed; install it with sdkmanager first. "Error: Invalid --device" means the -d profile name is wrong; list them with avdmanager list device. A hang means the interactive hardware-profile prompt was not answered; pipe echo "no". "PANIC: Cannot find AVD system path" at boot means the AVD references an image that was later removed.