简体   繁体   English

Android Gitlab CI模拟器不可见

[英]Android Gitlab CI emulator not visible

I want to set up Gitlab CI for my Android Things Project but the script always fails on connecting with an emulator. 我想为我的Android Things Project设置Gitlab CI,但是脚本在与仿真器连接时始终失败。

I can clearly see that the emulator is starting but the script android-wait-for-emulator doesn't recognise it. 我可以清楚地看到模拟器正在启动,但是脚本android-wait-for-emulator无法识别它。

Here is my YAML: 这是我的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

and the log: https://pastebin.com/EHEGxesM sorry for link to pastebin but the log is quite too long for stackoverflow. 和日志: https : //pastebin.com/EHEGxesM很抱歉,我无法链接到pastebin,但是日志对于stackoverflow来说太长了。

您可以尝试通过以下方式等待仿真器:

adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM