gpt4 book ai didi

java - Travis CI - android 构建失败。没有连接的设备错误

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

尝试为我的 Android 项目开始使用 Travis CI,但 Travis 在构建我的 Android 项目时仍然失败。

原因:

:app:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':app:connectedDebugAndroidTest'.

> com.android.builder.testing.api.DeviceException: No connected devices!

* Try:

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

BUILD FAILED

Travis 链接: https://travis-ci.org/hypeapps/Episodie/builds/158706530

.travis.yml:

language: android
jdk:
- oraclejdk8
before_install:
- chmod +x gradlew
env:
global:
- ANDROID_API_LEVEL=24
- EMULATOR_API_LEVEL=21
- ANDROID_BUILD_TOOLS_VERSION=24.0.1
- ANDROID_ABI=google_apis/armeabi-v7a
- ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default)
android:
components:
- tools
- tools
- platform-tools
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
- android-$ANDROID_API_LEVEL
- android-$EMULATOR_API_LEVEL
- extra
- add-on
- extra-google-m2repository
- extra-android-m2repository

# Google Play Services
- extra-google-google_play_services
# Support library
- extra-android-support

- addon-google_apis-google-$ANDROID_API_LEVEL
- addon-google_apis-google-$EMULATOR_API_LEVEL

- sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL
- sys-img-armeabi-v7a-addon-google_apis-google-$EMULATOR_API_LEVEL
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
before_script:
- echo no | android create avd --force -n test -t "Google Inc.:Google APIs:"$EMULATOR_API_LEVEL --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator

链接到 gradle 文件: build.gradle

Github 项目: GitHub

最佳答案

解决方法是:

在顶部添加一行:

sudo: false

创建模拟器管理:创建、启动和等待

before_script:
- echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &

现在 Travis CI 可以工作了。

关于java - Travis CI - android 构建失败。没有连接的设备错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39411060/

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