我想为我的Android Things Project设置Gitlab CI,但脚本总是在与模拟器连接时失败。
我可以清楚地看到模拟器正在启动,但脚本android-wait-for-emulator无法识别它。
这是我的YAML:
image: openjdk:8-jdk
variables:
ANDROID_COMPILE_SDK: "27"
ANDROID_BUILD_TOOLS: "27.0.3"
ANDROID_SDK_TOOLS: "27.0.1"
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
- unzip -q android-sdk.zip -d android-sdk-linux
- mkdir android-sdk-linux/licenses
- printf "8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e" > android-sdk-linux/licenses/android-sdk-license
- printf "84831b9409646a918e30573bab4c9c91346d8abd" > android-sdk-linux/licenses/android-sdk-preview-license
- android-sdk-linux/tools/bin/sdkmanager --update > update.log
- android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" "build-tools;${ANDROID_BUILD_TOOLS}" "extras;google;m2repository" "extras;android;m2repository" > installPlatform.log
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- chmod +x ./gradlew
stages:
- build
- test
build:
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
unitTests:
stage: test
script:
- ./gradlew test
functionalTests:
stage: test
script:
- wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
- chmod +x android-wait-for-emulator
- android-sdk-linux/tools/bin/sdkmanager "emulator" "system-images;android-${ANDROID_COMPILE_SDK};google_apis_playstore;x86"
- echo no | android-sdk-linux/tools/bin/avdmanager create avd -n test -k "system-images;android-${ANDROID_COMPILE_SDK};google_apis_playstore;x86"
- android-sdk-linux/tools/emulator -verbose -show-kernel -avd test -no-window -no-audio -no-accel -no-snapshot -gpu swiftshader_indirect &
- ./android-wait-for-emulator
- adb shell input keyevent 82
- ./gradlew connectedAndroidTest
和日志: https://pastebin.com/EHEGxesM 抱歉,链接到pastebin但是堆栈溢出的日志太长了。
答案 0 :(得分:0)
您可以尝试通过以下方式等待仿真器:
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done'