Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save psantos9/5f8a6e638d4e09272f4f763ad7d7bcd3 to your computer and use it in GitHub Desktop.

Select an option

Save psantos9/5f8a6e638d4e09272f4f763ad7d7bcd3 to your computer and use it in GitHub Desktop.
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

How to Install and Create Emulators using AVDMANAGER and SDKMANAGER

Installing system images

We pre-install these system images on the base build agent to provide our project teams the ability to run emulators on a range of API levels, from API 19 to API 28. X86 is the fastest architecture for emulators, though x86_64 would probably be better to test against because most phones are 64 bit now.

KITKAT

(4.4)

sdkmanager --install "system-images;android-19;google_apis;x86"

LOLLIPOP

(5.0)

sdkmanager --install "system-images;android-21;google_apis;x86"

(5.1)

sdkmanager --install "system-images;android-22;google_apis;x86"

MARSHMELLOW

(6.0)

sdkmanager --install "system-images;android-23;google_apis;x86"

NOUGAT

(7.0)

sdkmanager --install "system-images;android-24;google_apis;x86"

(7.1)

sdkmanager --install "system-images;android-25;google_apis;x86"

OREO

(8.0)

sdkmanager --install "system-images;android-26;google_apis;x86"

(8.1)

sdkmanager --install "system-images;android-27;google_apis;x86"

PIE

(9.0)

sdkmanager --install "system-images;android-28;google_apis;x86"

Using AVDMANAGER to create emulator

Pixel Emulator with Google Apis

Note: Add this alias to ~/.bashrc or ~/.zshrc, or just run using the command for best results. -skin 1080x1920 are useful to run Pixel at its desired resolution.

alias pixel_4.4 ='emulator @pixel_7.0_defaulttest -no-boot-anim -netdelay none -no-snapshot -wipe-data -skin 1080x1920 &'

echo "no" | avdmanager --verbose create avd --force --name "pixel_4.4" --device "pixel" --package "system-images;android-19;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "pixel_5.0" --device "pixel" --package "system-images;android-21;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "pixel_5.1" --device "pixel" --package "system-images;android-22;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "pixel_6.0" --device "pixel" --package "system-images;android-23;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "pixel_7.0" --device "pixel" --package "system-images;android-24;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "pixel_7.1" --device "pixel" --package "system-images;android-25;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "pixel_8.0" --device "pixel" --package "system-images;android-26;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "pixel_8.1" --device "pixel" --package "system-images;android-27;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "pixel_9.0" --device "pixel" --package "system-images;android-28;google_apis;x86" --tag "google_apis" --abi "x86"

Generic Emulator with Google Apis

echo "no" | avdmanager --verbose create avd --force --name "generic_4.4" --package "system-images;android-19;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "generic_5.0" --package "system-images;android-21;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "generic_5.1" --package "system-images;android-22;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "generic_6.0" --package "system-images;android-23;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "generic_7.0" --package "system-images;android-24;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "generic_7.1" --package "system-images;android-25;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "generic_8.0" --package "system-images;android-26;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "generic_8.1" --package "system-images;android-27;google_apis;x86" --tag "google_apis" --abi "x86"

echo "no" | avdmanager --verbose create avd --force --name "generic_9.0" --package "system-images;android-28;google_apis;x86" --tag "google_apis" --abi "x86"

Aliases to run emulators more optimally

Note: Add this alias to ~/.bashrc or ~/.zshrc, or just run using these parameters for best results. -skin 768x1280 is useful to run default emulators successfully because they have a very low resolution out-of-the-box.

alias generic_4.4 ='emulator @generic_4.4 -no-boot-anim -netdelay none -no-snapshot -wipe-data -skin 768x1280 &'

Note: Add this alias to ~/.bashrc or ~/.zshrc, or just run using these for best results. -skin 1080x1920 is useful to run Pixel at its desired resolution.

alias pixel_4.4 ='emulator @pixel_4.4 -no-boot-anim -netdelay none -no-snapshot -wipe-data -skin 1080x1920 &'

TODO

  1. Certain emulators, like Pixel, need to be started at a higher resolution than default oem emulators. Either define this in the ~/.android/avd/{name of avd}/config.ini file, or start emulator with -skin {RESOLUTION}.
  2. Find devices with avdmanager list avdmanager list target avdmanager list devices avdmanager list avd
-   avdmanager list              : Lists existing targets or virtual devices.
-   avdmanager list avd          : Lists existing Android Virtual Devices.
-   avdmanager list target       : Lists existing targets.
-   avdmanager list device       : Lists existing devices.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment