Skip to content

Instantly share code, notes, and snippets.

@pedrovgs
Last active August 15, 2021 10:04
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrovgs/6476e007ce3b570244c2b809f91aa577 to your computer and use it in GitHub Desktop.
Save pedrovgs/6476e007ce3b570244c2b809f91aa577 to your computer and use it in GitHub Desktop.
A ready to work emulator for Bitrise.io
#!/usr/bin/env bash
set -e
build_dir=$(pwd)
echo "Curren build dir:"
echo $build_dir
cd $ANDROID_HOME/emulator
echo "Creating sdcard image"
rm -rf sdcard.img
$ANDROID_HOME/tools/mksdcard -l e 1G sdcard.img
echo "SD card created"
echo "Creating emulator"
echo no | avdmanager create avd -n Nexus_5X_API_26 -k "system-images;android-26;google_apis;x86" --force --sdcard sdcard.img
echo "Original hardware profile"
cat ~/.android/avd/Nexus_5X_API_26.avd/config.ini
echo "Overriding hardware profile"
cp $build_dir/config.ini ~/.android/avd/Nexus_5X_API_26.avd/config.ini
echo "Updated hardware profile"
cat ~/.android/avd/Nexus_5X_API_26.avd/config.ini
echo "Emulator created. Starting emulator"
emulator -avd Nexus_5X_API_26 -no-window -no-audio -debug-init > /dev/null 2>&1 &
echo "Waiting emulator is ready..."
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
echo "Emulator is ready"
echo "Disabling animations"
$ANDROID_HOME/platform-tools/adb wait-for-device
$ANDROID_HOME/platform-tools/adb shell settings put global window_animation_scale 0
$ANDROID_HOME/platform-tools/adb shell settings put global transition_animation_scale 0
$ANDROID_HOME/platform-tools/adb shell settings put global animator_duration_scale 0
echo "Animations disabled and device boot started. Emulator ready to test"
PlayStore.enabled=false
abi.type=x86
avd.ini.encoding=UTF-8
hw.cpu.arch=x86
hw.sdCard=yes
image.sysdir.1=system-images/android-26/google_apis/x86/
sdcard.path=sdcard.img
tag.display=Google APIs
tag.id=google_apis
hw.lcd.density=320
hw.lcd.width=768
hw.lcd.height=1280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment