Skip to content

Instantly share code, notes, and snippets.

Last active November 9, 2023 14:00
Star You must be signed in to star a gist
What would you like to do?
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER


For an emulator that mimics a Pixel 5 Device with Google APIs and ARM architecture (for an M1/M2 Macbook):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-30;google_atd;arm64-v8a"

  3. Create Emulator: echo "no" | avdmanager --verbose create avd --force --name "pixel_5_api30_google_atd_emulator" --package "system-images;android-30;google_atd;arm64-v8a" --tag "google_atd" --abi "arm64-v8a" --device "pixel_5"

For M1/M2 Macbooks, use arm64-v8a as your "tag" or "target".

For Intel Macbooks use x86.

I recommend always using the new google_atd or aosp_atd images when possible. In my benchmarks, they are about 40% more efficient than the google_apis image.

Note: To check which devices you can create from the command line, run avdmanager list deviceand pass in the device name as the value of --device, e.g. --device "pixel_5" at the end of the command on step 3. (This includes tablets, etc)

Passing in a device will make the Emulator settings (usually found in the ~/.android/avd/emulator.avd/config.ini file) try to mimic that device. It is not actually the device. But, certain settings like pixel density, resolution, memory, partition size, etc will be changed. Generally the lower resolution devices will be less taxing on your CPU resources on CI, and are preferred especially without GPU/Hardware acceleration.


For generic skin emulator with default apis (without google apis) for use with Intel Macbook on CI (Can use google_atd too):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-30;aosp_atd;x86"

  3. Create Emulator: echo "no" | avdmanager --verbose create avd --force --name "generic_api30_aosp_atd_emulator" --package "system-images;android-30;aosp_atd;x86" --tag "aosp_atd" --abi "x86"

    If you do not use the --device flag, I recommend adding these lines to: ~/.android/avd/generic_10.avd/config.ini or else your emulator will have a very low resolution. 
    Note: Increasing resolution will decrease performance on CI.        # proper screen size for emulator
    hw.keyboard=yes            # enables keys from your laptop to be sent to the emulator
    If you cannot do this, you can still pass -skin 1080x1920 as an argument when starting the emulator. 
    Keep in mind, you can also pass the --device flag and use a device name from the avdmanager list device command which          should also set a default resolution because it will inherit the set of properties of that "device" in the config.ini.
  4. Run Emulator: emulator @generic_api30_aosp_atd_emulator & or emulator @pixel_5_google_atd_emulator &


See: Google's Emulator CLI Documentation for more info.

See: Google's AVDManager Documentation for more info.

See: Google's SDKManager Documentation for more info.


Add aliases to your ~/.zshrc or ~/.bashrc to run the emulators with parameters more easily.

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

alias pixel_5 ='emulator @pixel_5 -no-boot-anim -netdelay none -no-snapshot -wipe-data &'

Starting multiple emulators

You can pass the -read-only parameter when starting up an emulator emulator @pixel_5 -read-only to run multiple devices at the same time.


  1. aosp_atd and google_atd system images are only available on x86 and ARM architecture at API level 30.

See also:

Output of sdkmanager --list | grep atd:

  system-images;android-30;aosp_atd;arm64-v8a                                              | 1            | AOSP ATD ARM 64 v8a System Image
  system-images;android-30;aosp_atd;x86                                                    | 1            | AOSP ATD Intel x86 Atom System Image
  system-images;android-30;google_atd;arm64-v8a                                            | 1            | Google APIs ATD ARM 64 v8a System Image
  system-images;android-30;google_atd;x86                                                  | 1            | Google APIs ATD Intel x86 Atom System Image
  1. avdmanager list device is great to figure out which emulators you can create
  2. The newest cmdline-tools located at $HOME/Library/Android/sdk/cmdline-tools/latest/bin were created for Java 9/10/11. If you are running into issues running sdkmanager, make sure to update your path in your ~/.zshrc to the tools to the new tools if you are on Java 11, e.g. export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin. If you are still on Java 8, you can use the old tools.
Copy link

That fails too if I set ANDROID_HOME

$ANDROID_HOME/emulator/emulator -avd android28 -partition-size 2000
INFO    | Android emulator version (build_id 9058569) (CL:N/A)
emulator: INFO: checking ANDROID_HOME for valid sdk root...
emulator: INFO: checking ANDROID_SDK_ROOT for valid sdk root...
emulator: WARN: ANDROID_SDK_ROOT is missing.
emulator: WARN: Cannot find valid sdk root from environment variable ANDROID_HOME nor ANDROID_SDK_ROOT,Try to infer from emulator's path
emulator: INFO: guessed sdk root is /Users/cmoullia/Applications/sdk
emulator: WARN: platforms subdirectory is missing under /Users/cmoullia/Applications/sdk, please install it
emulator: WARN: invalid sdk root /Users/cmoullia/Applications/sdk
emulator: WARN: Cannot find valid sdk root path.
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

Copy link

It’s usually located in $HOME/Library/android/sdk/

I'm using the emulator installed under the sdk command line tools folder

total 8
drwxr-xr-x  10 cmoullia  staff  320 Oct  5 19:02 .
drwx------@ 11 cmoullia  staff  352 Oct  5 18:53 ..
drwxr-xr-x   3 cmoullia  staff   96 Oct  5 18:53 cmdline-tools
drwxr-xr-x  20 cmoullia  staff  640 Oct  5 19:00 emulator
drwxr-xr-x   4 cmoullia  staff  128 Oct  5 19:02 licenses
drwxr-xr-x   3 cmoullia  staff   96 Oct  5 18:54 patcher
drwxr-xr-x  18 cmoullia  staff  576 Oct  5 19:00 platform-tools
drwxr-xr-x   3 cmoullia  staff   96 Oct  5 19:02 system-images

ls -la $ANDROID_HOME/cmdline-tools/latest/bin 
total 112
drwxr-xr-x  9 cmoullia  staff   288 Oct  5 18:53 .
drwxr-xr-x  6 cmoullia  staff   192 Oct  5 18:53 ..
-rwxr-xr-x  1 cmoullia  staff  5319 Jan  1  2010 apkanalyzer
-rwxr-xr-x  1 cmoullia  staff  5310 Jan  1  2010 avdmanager
-rwxr-xr-x  1 cmoullia  staff  5278 Jan  1  2010 lint
-rwxr-xr-x  1 cmoullia  staff  5251 Jan  1  2010 profgen
-rwxr-xr-x  1 cmoullia  staff  5251 Jan  1  2010 retrace
-rwxr-xr-x  1 cmoullia  staff  5307 Jan  1  2010 screenshot2
-rwxr-xr-x  1 cmoullia  staff  5317 Jan  1  2010 sdkmanager

Copy link

mrk-han commented Oct 6, 2022

export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin

Copy link

This export will only allow to get the binaries under $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager|sdkmanager but not at all the emulator which is located under $ANDROID_HOME/emulator/emulator !

Copy link

There is a special config to be done to use the emulator coming from the cmdline-tools as we can do

export ANDROID_HOME=/Users/$(whoami)/Applications/sdk
cd $ANDROID_HOME/emulator/
./emulator -list-avds

but not

./emulator -avd android28 -partition-size 2000

Copy link

Was able to fix it after creating manually the missing folder platforms

mkdir -p $ANDROID_HOME/platforms

./emulator -avd android28 -partition-size 2000
INFO    | Android emulator version (build_id 9058569) (CL:N/A)
emulator: INFO: Found systemPath /Users/cmoullia/Applications/sdk/system-images/android-28/google_apis/x86/
emulator: INFO: Found systemPath /Users/cmoullia/Applications/sdk/system-images/android-28/google_apis/x86/
INFO    | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
INFO    | configAndStartRenderer: setting vsync to 60 hz
WARNING | cannot add library /Users/cmoullia/Applications/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
INFO    | added library /Users/cmoullia/Applications/sdk/emulator/lib64/vulkan/libvulkan.dylib
WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***
INFO    | Started GRPC server at, security: Local, auth: none
INFO    | Advertising in: /Users/cmoullia/Library/Caches/TemporaryItems/avd/running/pid_3987.ini
INFO    | setDisplayConfigs w 1080 h 2340 dpiX 440 dpiY 440

Copy link

why is it taking long installing, any help??

Copy link

Helped me to just set ANDROID_AVD_HOME manually ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment