Skip to content

Instantly share code, notes, and snippets.

@handstandsam
Created April 25, 2017 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save handstandsam/f20c2fd454d3e3948f428f62d73085df to your computer and use it in GitHub Desktop.
Save handstandsam/f20c2fd454d3e3948f428f62d73085df to your computer and use it in GitHub Desktop.
Script to Create Android Emulator for Espresso Tests on CI
AVD_NAME="384x640_mdpi_api_23"
echo "Creating (forceful) AVD with name ${AVD_NAME}"
# We have to echo "no" because it will ask us if we want to use a custom hardware profile, and we don't.
CREATE_AVD_COMMAND="android create avd \
--name ${AVD_NAME} \
--target android-23 \
--skin 384x640 \
--abi google_apis/x86_64 \
--force"
echo "Creating AVD"
echo "COMMAND: ${CREATE_AVD_COMMAND}"
echo "no" | ${CREATE_AVD_COMMAND}
echo "AVD ${AVD_NAME} created."
AVD_DIR=${HOME}/.android/avd
CONFIG_INI_PATH=${AVD_DIR}/${AVD_NAME}.avd/config.ini
# Customize AVD Properties
# vm.heapSize - Heap size needs to be larger than default (48) due to screenshots. After a while we get Out of Memory Exceptions otherwise.
# hw.mainKeys - Say there aren't hardware menu buttons
# hw.lcd.density - mdpi density
echo "vm.heapSize=128
hw.ramSize=1024
disk.dataPartition.size=4096MB
hw.gpu.enabled=yes
hw.gpu.mode=auto
hw.lcd.density=160
hw.keyboard=yes
hw.mainKeys=no" >> ${CONFIG_INI_PATH}
cat ${CONFIG_INI_PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment