2016-10-24 20 views
2

我目前正试图得到一个travis.yml适用于Android 24 /构建工具24.0.3和有一些麻烦。与Android Lib的特拉维斯CI - 没有兼容的设备连接

我有我的travis.yml如下:

language: android 
sudo: required 
jdk: oraclejdk8 

cache: 
    directories: 
    - ${TRAVIS_BUILD_DIR}/gradle/caches/ 
    - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ 

env: 
    global: 
    - ANDROID_API_LEVEL=24 
    - ANDROID_BUILD_TOOLS_VERSION=24.0.3 
    - ANDROID_ABI=armeabi-v7a 
    - ANDROID_TAG=google_apis 
    - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) 

android: 
    components: 
    - tools # to get the new `repository-11.xml` 
    - platform-tools 
    - tools # to install Android SDK tools 25.1.x 
    - build-tools-$ANDROID_BUILD_TOOLS_VERSION 
    - android-$ANDROID_API_LEVEL 
    # For Google APIs 
    - addon-google_apis-google-$ANDROID_API_LEVEL 
    # Support library 
    - extra-android-support 
    # Latest artifacts in local repository 
    - extra-google-m2repository 
    - extra-android-m2repository 
    # Specify at least one system image 
    - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL 

before_script: 
    - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG 
    - emulator -avd test -no-skin -no-window & 
    - android-wait-for-emulator 

script: 
    - ./gradlew clean jacocoDebugTestReport 

我现在的问题是,我不断收到:

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

或:

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself. 

这完全是两个单独的错误状态。

有没有人看到任何明显错误或不正确的关于我的travis.yml,可以帮助解释为什么它不工作。

回答

1

添加travis_wait,然后等待修复第二个问题。

before_script: 
    - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG 
    - emulator -avd test -no-skin -no-window & 
    - android-wait-for-emulator 
    - adb shell input keyevent 82 & 

script: 
    - travis_wait 20 ./gradlew clean jacocoDebugTestReport 

如果你解决了第一个问题,可能你不需要以前的解决方案。

下面的线通常是必要的,我没有测试它在Android-24,我需要看到一个完整的日志

- adb shell input keyevent 82 & 

作为一种变通方法,我会用较低的API级别的建议here,直到找到更好的解决方案。

过去两年我花了很多空闲时间试图找到这类问题的解决方案,最好的办法就是使用ci版本构建较低的API和设备或对最近的API进行本地测试。

如果您考虑解决问题所需的时间,那么使用最新的API的好处是不够的。

1

详细阐述了Ardock发布的内容,我能够通过降低仿真器SDK级别来解决我的问题。我的工作是travis.yml:

language: android 
jdk: oraclejdk8 
sudo: false 

android: 
    components: 
    - platform-tools 
    - tools 
    - build-tools-24.0.3 
    - android-22 
    - android-24 
    - sys-img-armeabi-v7a-android-22 
    - extra-android-m2repository 
    - extra-android-support 
    - extra-google-m2repository 

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

script: ./gradlew clean connectedAndroidTest -PdisablePreDex --stacktrace 

它不必下载和安装多个SDK超级优雅,但https://github.com/isuPatches/WiseFy/commits/masterhttps://travis-ci.org/isuPatches/WiseFy/builds表明,它的工作。

+0

感谢您分享您的工作解决方案。真的,下载这两个平台是正确的。你的[sdk目标](https://github.com/ardock/android-topeka/blob/acib/scripts/acib#L49)和每个[模拟器目标](https://github.com/ardock/android-topeka /blob/acib/.travis.yml#L27)。以前的平台是[预安装的](https://github.com/travis-ci/travis-cookbooks/blob/a68419ebe0ce92876a70534cd145ddd931d0feee/ci_environment/android-sdk/attributes/default.rb)。 – albodelu