1#!/usr/bin/env bash 2 3API_LEVEL=$1 4emulator_name="bare-expo" 5 6if $ANDROID_HOME/tools/android list avd | grep -q $emulator_name; then 7 echo " ☛ Found an existing an emulator named ${emulator_name}" 8 exit 0; 9fi 10 11if [ $API_LEVEL -eq 21 ] 12then 13 PACKAGE="system-images;android-21;default;x86_64" 14elif [ $API_LEVEL -eq 22 ] 15then 16 PACKAGE="system-images;android-22;default;x86_64" 17elif [ $API_LEVEL -eq 23 ] 18then 19 PACKAGE="system-images;android-23;default;x86_64" 20elif [ $API_LEVEL -eq 24 ] 21then 22 PACKAGE="system-images;android-24;default;x86_64" 23fi 24 25echo " ☛ Downloading the Android image to create an emulator..." 26echo no | $ANDROID_HOME/tools/bin/sdkmanager $PACKAGE 27 28echo " ☛ Creating the emulator..." 29echo no | $ANDROID_HOME/tools/bin/avdmanager \ 30 --verbose \ 31 create avd \ 32 --force \ 33 --name ${emulator_name} \ 34 --abi default/x86_64 \ 35 --package $PACKAGE \ 36 --sdcard 300M 37 38echo " ☛ Configuring the emulator..." 39 40cat >> $HOME/.android/avd/${emulator_name}.avd/config.ini << EOF 41hw.ramSize=2048 42hw.gpu.enabled=yes 43hw.gpu.mode=host 44hw.keyboard=yes 45hw.camera.front=emulated 46hw.camera.back=virtualscene 47hw.cpu.arch=x86_64 48hw.sdCard=yes 49hw.lcd.density=240 50hw.lcd.width=480 51hw.lcd.height=800 52showDeviceFrame=yes 53skin.path=_no_skin 54PlayStore.enabled=false 55abi.type=x86_64 56avd.ini.encoding=UTF-8 57image.sysdir.1=system-images/android-22/default/x86_64/ 58tag.id=default 59tag.display= 60EOF 61 62echo " ☛ Emulator created" 63 64