Gitlab CI模拟器未启动

问题描述 投票:0回答:1

我对GitLab上的配置项有疑问。几天前它一直在工作,但没有进行任何更改,它停止了工作。仿真器不再启动,并且作业总是在超时后完成。

以下是作业失败时的日志(full log):

[ ... ]

$ 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 --update > update.log
Warning: File /root/.android/repositories.cfg could not be loaded.
$ android-sdk-linux/tools/bin/sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"  > installEmulator.log
Warning: File /root/.android/repositories.cfg could not be loaded.
$ echo no | android-sdk-linux/tools/bin/avdmanager create avd --force --name test --abi google_apis/x86_64 --package "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"
Loading local repository...                                                     
[=========                              ] 25% Loading local repository...       
[=========                              ] 25% Fetch remote repository...        
[=========                              ] 25% Fetch remote repository...        
[=========                              ] 25% Fetch remote repository...        
[=======================================] 100% Fetch remote repository...       
Do you wish to create a custom hardware profile? [no] $ android-sdk-linux/emulator/emulator -avd test -no-window -no-audio &
$ ./android-wait-for-emulator
statvfs('/root/.android/avd/test.avd/snapshots/default_boot/ram.img') failed: No such file or directory
Waiting for emulator to start
Pulling docker image gitlab/gitlab-runner-helper:x86_64-577f813d ...
ERROR: Job failed: execution took longer than 1h0m0s seconds

这里是EXACT SAME作业工作时的日志(full log

[ ... ]

$ 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 --update > update.log
Warning: File /root/.android/repositories.cfg could not be loaded.
$ android-sdk-linux/tools/bin/sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"  > installEmulator.log
Warning: File /root/.android/repositories.cfg could not be loaded.
$ echo no | android-sdk-linux/tools/bin/avdmanager create avd --force --name test --abi google_apis/x86_64 --package "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"
Loading local repository...                                                     
[=========                              ] 25% Loading local repository...       
[=========                              ] 25% Fetch remote repository...        
[=========                              ] 25% Fetch remote repository...        
[=========                              ] 25% Fetch remote repository...        
[=======================================] 100% Fetch remote repository...       
Do you wish to create a custom hardware profile? [no] $ android-sdk-linux/emulator/emulator -avd test -no-window -no-audio &
$ ./android-wait-for-emulator
statvfs('/root/.android/avd/test.avd/snapshots/default_boot/ram.img') failed: No such file or directory
Waiting for emulator to start
Your emulator is out of date, please update by launching Android Studio:
 - Start Android Studio
 - Select menu "Tools > Android > SDK Manager"
 - Click "SDK Tools" tab
 - Check "Android Emulator" checkbox
 - Click "OK"

Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
Waiting for emulator to start
emulator: INFO: boot completed
emulator: INFO: boot time 23881 ms
emulator: Increasing screen off timeout, logcat buffer size to 2M.
emulator: Revoking microphone permissions for Google App.
Emulator is ready
$ adb shell settings put global window_animation_scale 0 &
$ adb shell settings put global transition_animation_scale 0 &
$ adb shell settings put global animator_duration_scale 0 &
$ adb shell input keyevent 82
$ cd ./DenisAppProject
$ ./gradlew connectedCheck

[ ... ]

$ adb emu kill
OK: killing emulator, bye bye
OK
emulator: Saving state on exit with session uptime 146931 ms
Job succeeded

这是我的gitlab-ci.yml

    image: openjdk:8-jdk

    variables:
      ANDROID_COMPILE_SDK: "28"
      ANDROID_BUILD_TOOLS: "28.0.3"
      ANDROID_SDK_TOOLS:   "4333796"
      EMULATOR_VERSION: "26"

    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-${ANDROID_SDK_TOOLS}.zip
      - unzip -d android-sdk-linux android-sdk.zip
      - echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
      - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
      - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
      - export ANDROID_HOME=$PWD/android-sdk-linux
      - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
      - chmod +x ./DenisAppProject/gradlew
      # temporarily disable checking for EPIPE error and use yes to accept all licenses
      - set +o pipefail
      - yes | android-sdk-linux/tools/bin/sdkmanager --licenses
      - set -o pipefail

    stages:
      - build
      - unit-test
      - instrumental-test

    lintDebug:
      tags: ["android"]
      stage: build
      script:
        - cd DenisAppProject/
        - ./gradlew -Pci --console=plain :DenisApp:lintDebug -PbuildDir=lint

    assembleDebug:
      tags: ["android"]
      stage: build
      script:
        - cd DenisAppProject/
        - ./gradlew assembleDebug
      artifacts:
        paths:
        - DenisApp/build/outputs/

    debugTests:
      tags: ["android"]
      stage: unit-test
      script:
        - cd DenisAppProject/
        - ./gradlew -Pci --console=plain :DenisApp:testDebug

    instrumentation_tests:
      tags: ["android"]
      stage: instrumental-test
      script:
        - apt-get --quiet update --yes
        - apt-get --quiet install --yes libx11-dev libpulse0 libgl1 libnss3 libxcomposite-dev libxcursor1 libasound2
        - 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 --update > update.log
        - android-sdk-linux/tools/bin/sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"  > installEmulator.log
        - echo no | android-sdk-linux/tools/bin/avdmanager create avd --force --name test --abi google_apis/x86_64 --package "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"
        - android-sdk-linux/emulator/emulator -avd test -no-window -no-audio &
        - ./android-wait-for-emulator
        # Turn off animations
        - adb shell settings put global window_animation_scale 0 &
        - adb shell settings put global transition_animation_scale 0 &
        - adb shell settings put global animator_duration_scale 0 &
        - adb shell input keyevent 82
        - cd ./DenisAppProject
        - ./gradlew connectedCheck
        - adb emu kill

该作业的屏幕,您可以在其中看到它是第一次工作,然后停止(之前所有的工作都在工作)。 Screen

docker android-emulator gitlab gitlab-ci gitlab-ci-runner
1个回答
0
投票

最后,我在docker本地复制了相同的环境。然后,我可以尝试使用日志启动仿真器,然后发现存在分段错误错误,在进行其他一些测试之后,我发现采用正常的仿真器版本而不是64版本可以解决我的问题,我还添加了一些参数来禁用gpu,开始的动画等。它不能解释为什么突然停止工作,但至少此命令有效:

- android-sdk-linux/emulator/emulator -avd test -no-boot-anim -no-snapshot-save -no-audio -no-window -gpu off -debug  -all

并使用模拟器图像

system-images;android-${ANDROID_COMPILE_SDK};google_apis_playstore;x86

© www.soinside.com 2019 - 2024. All rights reserved.