我在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
答案 0 :(得分:1)
@ Denis-Pinna 嗨,我尝试第一次设置gitlab CI。创建后启动ii时,出现以下错误。
等待模拟器启动 仿真器:错误:x86仿真当前需要硬件加速! 请确保正确安装了KVM并可以使用它。 CPU加速状态:KVM需要支持vmx或svm的CPU 有关在Linux上配置VM加速的更多信息: https://developer.android.com/studio/run/emulator-acceleration#vm-linux 有关加速的一般信息:https://developer.android.com/studio/run/emulator-acceleration。
答案 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