diff --git a/.travis.yml b/.travis.yml index ba37552..00009a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,28 @@ language: android -dist: trusty + +jdk: oraclejdk8 + +env: + global: + - ANDROID_TARGET=android-22 + - ANDROID_ABI=armeabi-v7a + android: components: - - build-tools-26.0.2 - - android-26 - - extra + - tools + - platform-tools + - build-tools-28.0.3 + - android-28 + - $ANDROID_TARGET + - extra-android-m2repository + - sys-img-${ANDROID_ABI}-${ANDROID_TARGET} + +before_script: + - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI -c 100M + - emulator -avd test -no-window & + - bash ./tools/android-wait-for-emulator.sh + - adb shell input keyevent 82 & + +script: + - bash ./gradlew build + - bash ./gradlew test -x lint --stacktrace diff --git a/tools/android-wait-for-emulator.sh b/tools/android-wait-for-emulator.sh new file mode 100644 index 0000000..aa6345d --- /dev/null +++ b/tools/android-wait-for-emulator.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Originally written by Ralf Kistner , but placed in the public domain + +set +e + +bootanim="" +failcounter=0 +timeout_in_sec=360 + +until [[ "$bootanim" =~ "stopped" ]]; do + bootanim=`adb -e shell getprop init.svc.bootanim 2>&1 &` + if [[ "$bootanim" =~ "device not found" || "$bootanim" =~ "device offline" + || "$bootanim" =~ "running" ]]; then + let "failcounter += 1" + echo "Waiting for emulator to start" + if [[ $failcounter -gt timeout_in_sec ]]; then + echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator" + exit 1 + fi + fi + sleep 1 +done + +echo "Emulator is ready"