如何使用Travis CI上的构建矩阵设置运行API 25的模拟器? [英] How to setup an emulator running API 25 using a build matrix on Travis CI?

查看:287
本文介绍了如何使用Travis CI上的构建矩阵设置运行API 25的模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置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 
有效ABI:无ABI。
错误:所选目标无效--abi armeabi-v7a。

android列表目标的输出显示API 19仿真器有一个Tag / ABI,而API 25仿真器没有:

  id:7或android-19 
名称:Android 4.4.2
类型:平台
API级别:19
修订版:4
皮肤:HVGA,QVGA,WQVGA400,WQVGA432,WSVGA,WVGA800 (默认),WVGA854,WXGA720,WXGA800,WXGA800-7in
标签/ ABIs:默认/ armeabi-v7a

id:11或android-25
名称:Android 7.1.1
类型:平台
API级别:25
修订版:3
皮肤:HVGA,QVGA,WQVGA400,WQVGA432,WSVGA,WVGA800(默认),WVGA854,WXGA720, WXGA800,WXGA800-7in
标签/ ABI:无ABI。

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



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

 语言:android 

android:
组件:
- 工具
- platform-tools
- 工具#出现两次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:
矩阵:
- 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:
#创建并启动模拟器
- android列表目标
- jdk_switcher使用oraclej dk8
- 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
- 而[[`adb shell pm path android` =='Error'*]];睡觉2;完成
- adb shell输入keyevent 82&

脚本:./ gradlew --info connectedAndroidTest

sudo:false


解决方案

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



注意:模拟器版本26.1.3是



使用模拟器的相关问题26.1.2






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




  • 使用系统映像 google_apis 简化构建矩阵并避免遗漏ABI。

  • 使用新的 sdkmanager avdmanager

  • 使用新的Trusty图像,包括ese工具简化Travis-ci配置或者使用 dist:precise ,如解释这里



参见下面的链接使用包含Api-25模拟器的构建矩阵。






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



我提供了一个可能的解决方案到Ashish Pathak评论的问题(我也是ardock) 此处



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



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






正如宣布在此博客文章中


所有Ubuntu Trusty 14.04图像都有更新



新一代Trusty图像是已经可以在
生产中使用,可以通过在.travis.yml
文件中添加group:edge来使用:




  sudo:必需
dist:trusty

group:edge#添加此

此处所述:


作为更多信息,这个新的Android图像附带:



Android SDK 25.2.3 build-tools-25.0.2



新的sdkmanager工具 - 一个命令行工具,允许您查看,
安装,更新和卸载Android SDK的包。替换以前的android工具
,请参阅
https:/ /developer.android.com/studio/tools/help/android.html



此外,新的Android图像应该是复古兼容的。查看可在
.travis.yml文件中指定的完整
Android SDK组件列表,包括build-tools-26.0.0-preview。




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



或者,你可以通过添加 dist:exact 来使用之前的图像。






下面的行是图片更新前我对相关问题的回答:的一部分:



使用约束布局codelab存储库的完整工作示例API级别22到25:



另外两个样本使用 sdkmanager avdmanager





参考资料



使用Gradle自动下载丢失的软件包相关的官方文档



新的模拟器选项在从命令行启动模拟器



avdmanager 此处解释替换 android avd ,因为 SDK工具版本25.3.0



sdkmanager 此处说明也得到了增强,可以从命令行查看和接受所有许可


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, with the following message:

$ 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.

The output of android list targets shows that the API 19 emulator has a Tag/ABI, whereas the API 25 emulator does not:

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.

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

The full .travis.yml file is as follows:

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

解决方案

Note: emulator version 26.1.4+ versions can introduce or fix bugs. If a reproducible ci build is required, the best option is to download the desired sdk-tools version no via android components.

Note: emulator version 26.1.3 is here including interesting fixes. I'm busy to revise my answer now:

Related issue using emulator 26.1.2 here. Relaunch last build like me to use 26.1.3 and pray, green

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?

Update: I confirmed that ARM ABIs for APIs 23, 25 and 26 are also missing in Android Studio, so:

  • It's not a Travis-ci issue. I reproduced it locally as shown in the next image.

  • You can use ARM ABI for API-24. I forked your project and it worked in build #6 (next image).

  • You can use Google APIs image for API-25 as I explain below using the new sdkmanager: 1

  • You can use Google APIs image for API-25 using legacy tools if you know the img name: 1,2,3

  • We need to ask to Google or someone else why the ARM ABIs for these APIs are missing.

Update: A related bug was already reported to Google and discussed here, please, star it:

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.


I'm not sure if the api-25 issue is related but I expect that it will work combining several solutions:

  • Use system images with google_apis to simplify the build matrix and avoid missing ABIs.
  • Use the new sdkmanager and avdmanager required by the recent Sdk Tools.
  • Use the new Trusty images including these tools to simplify the Travis-ci configuration or alternatively use dist: precise as explained here.

See the links below to working samples using a build matrix that includes Api-25 emulator.


I updated the api 23 system image one time on a macbook via Android Studio and appeared a message about the new version was not supported by my computer, so I use the google_apis one.

I offer a possible solution to the issue commented by Ashish Pathak (I'm also ardock) here.

I need to update my response to support the new Travis-ci images that comes with new SDK tools.

The new pre-installed Sdk Tools will simplify the solution and reduce the YAML file in size.


As announced in this blog post by Carmen Andoh and Dominic Jodoin on 19 Jun 2017:

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

And as explained 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.

But they are not using the new avdmanager, I'll try to fix it this weekend.

Alternatively, you can use the previous images by adding dist: precise.


The lines below are part of my answer on a related question: prior to the images update:

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

Two more samples using sdkmanager and avdmanager:

References

Official documentation related to Auto-download missing packages with Gradle

The new Emulator options are explained in Start the Emulator from the Command Line

avdmanager explained here replaces android avd since SDK tools version 25.3.0

sdkmanager explained here also enhanced to view and accept all licenses from the command line

这篇关于如何使用Travis CI上的构建矩阵设置运行API 25的模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆