# doing android emulator stuff manual
$ANDROID_HOME/platform-tools/adb start-server
$ANDROID_HOME/emulator/emulator -prop persist.sys.language=de -prop persist.sys.country=DE -avd $AVD_IMAGE -no-window -no-audio &
EMULATOR_PID=$!
# Wait for Android to finish booting
WAIT_CMD="$ANDROID_HOME/platform-tools/adb wait-for-device shell getprop init.svc.bootanim"
until $WAIT_CMD | grep -m 1 stopped; do
echo "Waiting..."
sleep 1
done
[ -d build ] || mkdir build
$ANDROID_HOME/platform-tools/adb shell logcat -v time > build/logcat.log &
LOGCAT_PID=$!
$ANDROID_HOME/platform-tools/adb shell wm dismiss-keyguard
$ANDROID_HOME/platform-tools/adb shell input keyevent 4
# run tests
./gradlew --continue test lint connectedAndroidTest || echo "failed"
# Stop the background processes
kill $LOGCAT_PID
kill $EMULATOR_PID