java - 如何使用 Travis CI 上的构建矩阵设置运行 API 25 的模拟器?

标签 java android continuous-integration travis-ci

我正在尝试设置 Travis CI,以便它在运行 API 25 的模拟器上运行仪器测试。Travis 在 API 4/10/19 上运行测试直至完成,但无法启动 API 25 的模拟器,如下所示留言:

$ echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
Valid ABIs: no ABIs.
Error: Invalid --abi armeabi-v7a for the selected target.

android list targets 的输出显示 API 19 模拟器有标签/ABI,而 API 25 模拟器没有:

id: 7 or "android-19"
     Name: Android 4.4.2
     Type: Platform
     API level: 19
     Revision: 4
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : default/armeabi-v7a

id: 11 or "android-25"
     Name: Android 7.1.1
     Type: Platform
     API level: 25
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.

如何解决此问题,以便 API 25 模拟器启动并运行测试?

完整的.travis.yml文件如下:

language: android

android:
  components:
    - tools
    - platform-tools
    - tools # appears twice as per Travis docs
    - build-tools-23.0.1
    - build-tools-25.0.2
    - android-4
    - android-10
    - android-19
    - android-23
    - android-25
    - extra-android-m2repository
    - sys-img-armeabi-v7a-android-25

env:
  matrix:
    - ANDROID_TARGET=android-4 ANDROID_ABI=armeabi
    - ANDROID_TARGET=android-10 ANDROID_ABI=armeabi
    - ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
    - ANDROID_TARGET=android-25 ANDROID_ABI=armeabi-v7a

before_script:
  # Create and start emulator
  - android list targets
  - jdk_switcher use oraclejdk8
  - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
  - emulator -avd test -no-skin -no-audio -no-window &
  - adb wait-for-device
  - while [[ `adb shell pm path android` == 'Error'* ]]; do sleep 2; done
  - adb shell input keyevent 82 &

script: ./gradlew --info connectedAndroidTest

sudo: false

最佳答案

注意:模拟器版本 26.1.4+ 版本可以引入或修复错误。如果需要可重现的 ci 构建,最好的选择是通过 android 组件下载所需的 sdk-tools 版本号。

注意:模拟器版本 26.1.3 是 here包括有趣的修复。我现在正忙着修改我的答案:

enter image description here

使用模拟器 26.1.2 的相关问题 here .重新启动上次构建 like me使用 26.1.3 并祈祷,绿色

I am attempting to setup Travis CI so that it runs instrumentation tests on an emulator running API 25. Travis runs the tests to completion on API 4/10/19, but fails to startup the emulator for API 25...

How can I fix this so that the API 25 emulator launches and runs the tests?

更新:我确认 Android Studio 中也缺少用于 API 23、25 和 26 的 ARM ABI,因此:

  • 这不是 Travis-ci 问题。我在本地复制了它,如下图所示。

  • 您可以将 ARM ABI 用于 API-24。我 fork 了你的项目,它在构建 #6 中工作(下一张图片)。

  • 您可以将 Google API 图像用于 API-25,正如我在下面使用新的 sdkmanager 所解释的那样:1

  • 如果您知道 img 名称:1,您可以使用遗留工具将 Google API 图像用于 API-25。 , 2 , 3

  • 我们需要向 Google 或其他人询问为什么缺少这些 API 的 ARM ABI。

更新: A related bug已经报告给谷歌并讨论了here , 请加注星标:

For some reason it's marked as being only available on windows. I'm not sure if this is a problem with ADRT itself or the configuration for this package, but from a quick look it seems like it's probably a problem with adrt itself.

enter image description here

enter image description here


我不确定 api-25 问题是否相关,但我希望它能结合多种解决方案:

  • 将系统镜像与 google_apis 结合使用以简化构建矩阵并避免遗漏 ABI。
  • 使用最新的 Sdk 工具所需的新 sdkmanageravdmanager
  • 使用包含这些工具的新 Trusty 图像来简化 Travis-ci 配置,或者使用 dist: precise 作为解释 here .

请参阅下面的链接,了解使用包含 Api-25 模拟器的构建矩阵的工作示例。


我在 macbook 上通过 Android Studio 更新了 api 23 系统镜像一次,并出现一条关于我的计算机不支持新版本的消息,所以我使用了 google_apis。

我为 issue 提供了一个可能的解决方案Ashish Pathak 评论(我也是 ardock)here .

我需要更新我的回复以支持新 SDK 工具附带的新 Travis-ci 图像。

新的预装 Sdk 工具将简化解决方案并减小 YAML 文件的大小。


如公告in this blog post作者:Carmen Andoh 和 Dominic Jodoin,2017 年 6 月 19 日:

Updates are coming to all Ubuntu Trusty 14.04 images

This new generation of Trusty images is already available in production and can be used by adding group: edge in your .travis.yml file:

sudo: required
dist: trusty

group: edge  # Add this

正如解释的那样here :

As a bit more information, this new Android image comes with:

Android SDK 25.2.3 build-tools-25.0.2

The new sdkmanager tool - a command line tool that allows you to view, install, update, and uninstall packages for the Android SDK. Replaces the previous android tool, see https://developer.android.com/studio/tools/help/android.html

Also, the new Android image should be retro-compatible. See the full list of Android SDK components that can be specified in the .travis.yml file, including build-tools-26.0.0-preview.

但他们没有使用新的 avdmanager,我将在本周末尝试修复它。

或者,您可以通过添加 dist: precise 来使用以前的图像。


以下几行是 my answer on a related question: 的一部分在图像更新之前:

Full working sample using constraint-layout codelab repository for Android API level 22 to 25:

另外两个使用 sdkmanageravdmanager 的示例:

引用资料

Auto-download missing packages with Gradle相关的官方文档

new Emulator Start the Emulator from the Command Line 中解释了选项

avdmanager explained hereSDK tools version 25.3.0 以来替换 android avd

sdkmanager explained here还增强了从命令行查看和接受所有许可证

关于java - 如何使用 Travis CI 上的构建矩阵设置运行 API 25 的模拟器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45100298/

相关文章:

java - maven:将资源从依赖 jar 复制到目标文件夹

master 的 jenkins 运行多个下游作业

java - HttpSession 中的同步是否可行?

Java设置数组文本颜色

java - 为什么这个 boolean 方法使用错误的返回路径?

java - LIBGDX - 碰撞问题和滑动效果问题

Android:使用 Context.startService 与 PendingIntent.getService 启动服务

continuous-integration - 我如何使用 TeamCity 安全地进行生产发布?

jenkins - 如何在没有网页界面的情况下向 Jenkins 添加帐户?

java - JSR 310 : Converting between time zones