gpt4 book ai didi

android - 运行仪器测试 ionic Gitlab CI 时出现不兼容的 AVD 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:14:41 25 4
gpt4 key购买 nike

每当我尝试为我的 android 项目运行仪器测试时,我都会遇到以下错误:

Skipping device 'test(AVD)' for 'app:': Unknown API Level

> : No compatible devices connected.[TestRunner] FAILED
Found 1 connected device(s), 0 of which were compatible.
:app:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///builds/antitheft/anti-theft-screen-lock/app/build/reports/androidTests/connected/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2 mins 45.163 secs
ERROR: Job failed: exit code 1

我正在使用共享运行器。我的目标 API 是 25,我正在尝试在 API 22 上运行 AVD。

这是我的 gitlab-ci.yml 文件:

image: openjdk:8-jdk

variables:
ADB_INSTALL_TIMEOUT: "5"
ANDROID_COMPILE_SDK: "25"
ANDROID_TEST_SDK: "22"
ANDROID_ABI: "armeabi-v7a"
ANDROID_BUILD_TOOLS: "25.0.2"
ANDROID_SDK_TOOLS: "24.4.1"
IS_CI_BUILD : "true"

before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz
- tar --extract --gzip --file=android-sdk.tgz
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_COMPILE_SDK}
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_TEST_SDK}
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS}
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- chmod +x ./gradlew

stages:
- build #Generates the release and debug build
- test #Performs unit and insttrumentation tests.

debugBuild: #Generate debug build for dev and master branch
stage: build
script:
- ./gradlew assembleDebug
only:
- master
- dev
artifacts:
paths:
- app/build/outputs/

unitTests: #Unit tests
stage: test
script:
#Run the unit test
- ./gradlew test

functionalTests: #Instrumantation tests
stage: test
script:
#Download the wait for emulator 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

#Download emulator image for armeabi-v7a
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter sys-img-armeabi-v7a-google_apis-${ANDROID_TEST_SDK}

#Create AVD
- echo no | android-sdk-linux/tools/android create avd --force -n test -t android-${ANDROID_TEST_SDK} --abi google_apis/armeabi-v7a

#Start the AVD and wait for the emulator to start
- android-sdk-linux/tools/emulator64-arm -avd test -no-audio -no-window &
- ./android-wait-for-emulator

#Display list of devices
- adb devices

#Unloack device and run the instrumantation test
- adb shell input keyevent 82 &
- ./gradlew connectedAndroidTest

帮我解决这个问题。我试图在过去的 4-5 天内运行它,但没有成功。

谢谢。

最佳答案

我也遇到过类似的问题,最后我通过这个配置成功了

image: gengjiawen/android-ndk

stages:
- build
- test

build:
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/

unitTests:
stage: test
script:
- ./gradlew test

functionalTests:
stage: test
script:
- sdkmanager "system-images;android-24;default;armeabi-v7a"
- echo no | avdmanager create avd --force -n test -k "system-images;android-24;default;armeabi-v7a"
- emulator -avd test -no-audio -no-window &
- wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/master/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
- chmod +x android-wait-for-emulator
- ./android-wait-for-emulator
- adb shell input keyevent 82
- ./gradlew cAT

关于android - 运行仪器测试 ionic Gitlab CI 时出现不兼容的 AVD 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43245492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com