简体   繁体   English

使用Gradle的Travis-CI Android测试可以防止超时

[英]Travis-CI Android tests with Gradle keep timing out

I'm trying to build & test my project on Travis CI. 我正在尝试在Travis CI上构建和测试我的项目。 It keeps showing me same repetitive output every time on all my repositories. 它每次都在我的所有存储库上不断向我显示相同的重复输出。

Here is my travis.yml https://github.com/carts-uiet/cartsbusboarding/blob/master/.travis.yml 这是我的travis.yml https://github.com/carts-uiet/cartsbusboarding/blob/master/.travis.yml

language: android
    android:
    components:
    # Uncomment the lines below if you want to
    # use the latest revision of Android SDK Tools
    # - platform-tools
    # - tools
    # The BuildTools version used by your project
    - build-tools-21.0.0
    # The SDK version used to compile your project
    - android-21
    # Additional components
    - add-on
    - extra
    # Specify at least one system image,
    # if you need to run emulator(s) during your tests
    - sys-img-armeabi-v7a-android-21
    # Emulator Management: Create, Start and Wait
    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 &

Here is one such build https://travis-ci.org/carts-uiet/cartsbusboarding/builds/39447907 这是一个这样的构建https://travis-ci.org/carts-uiet/cartsbusboarding/builds/39447907

$ javac -version
javac 1.7.0_60
before_script.1
3.53s$ echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
Android 5.0 is a basic Android platform.
Do you wish to create a custom hardware profile [no]Created AVD 'test' based on Android 5.0, ARM (armeabi-v7a) processor,
with the following hardware config:
hw.cpu.model=cortex-a8
hw.lcd.density=240
hw.ramSize=512
vm.heapSize=48
before_script.2
0.01s
$ emulator -avd test -no-skin -no-audio -no-window &
$ android-wait-for-emulator
Failed to Initialize backend EGL display
emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
error: device offline
error: device offline
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
error: device offline
error: device offline
running
running
running
running
running
running

All these builds time-out. 所有这些都构建了超时。

What am I doing wrong here? 我在这做错了什么?

Updated response: VM images already include fixed android-wait-for-emulator script and android SDK tools version 24.0.0 by default solving this issue. 更新的响应: VM映像已经包含固定的android-wait-for-emulator脚本和android SDK工具版本24.0.0,默认情况下解决了这个问题。 I deleted my outdated response and workaround. 我删除了过时的响应和解决方法。

Build Environment Updates - 2014-12-09 构建环境更新 - 2014-12-09

This sounds like the best alternative to get the latest version of the script: 这听起来像是获取最新版脚本的最佳选择:

I added this to my before script: 我在前脚本中添加了这个:

# Emulator Management: Create, Start and Wait
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 &
  - curl http://is.gd/android_wait_for_emulator > android-wait-for-emulator
  - chmod u+x android-wait-for-emulator
  - ./android-wait-for-emulator
  - adb shell input keyevent 82 &

The url points to the latest script available on github. 该url指向github上提供的最新脚本。

Hope that helps . 希望有所帮助。 . .

You need to instruct your travis build to actually run unit tests: 您需要指示您的travis构建实际运行单元测试:

# run tests  against the emulator
- ./gradlew connectedAndroidTest
# run tests  against the JVM
- ./gradlew test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM