travis-ci build使用ShellCommandUnresponsiveException保持失败

时间:2015-10-29 00:05:26

标签: android travis-ci

我正在尝试使用travis-ci来处理我的Android应用程序。如果我只执行assembleDebug它工作正常。但我也希望运行测试并生成代码覆盖率。这是我现在的配置:

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-23.0.1

    # The SDK version used to compile your project
    - android-23

    # Additional components
    # - extra-google-google_play_services
    # - extra-google-m2repository
    - extra-android-m2repository
    # - addon-google_apis-google-19

    # Specify at least one system image,
    # if you need to run emulator(s) during your tests
    - sys-img-armeabi-v7a-android-23

env:
  global:
    # install timeout in minutes (2 minutes by default)
    - ADB_INSTALL_TIMEOUT=8

before_install:
 - chmod +x gradlew
 - pip install --user codecov

# Emulator Management: Create, Start and Wait
before_script:
  - echo no | android create avd --force --name test --target android-23 --abi armeabi-v7a
  - emulator -avd test -no-skin -no-audio -no-window -no-boot-anim &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &

script:
  - ./gradlew build connectedCheck --stacktrace
  #  - ./gradlew assembleDebug

after_success:
  - codecov

尽管我已将ShellCommandUnresponsiveException全局变量设置为8(source),但构建仍会以ADB_INSTALL_TIMEOUT失败。构建本身甚至没有运行8分钟,所以它失败的原因很奇怪。

我尝试删除所有资源文件,以使应用尽可能小。但这没有帮助。

失败的版本可以在travis分支下找到https://travis-ci.org/Longi94/bptf/branches,我试图让它工作。有一个成功的构建。我不知道它是怎么过去的。

以下是构建日志失败的一部分:

[0K$ echo no | android create avd --force --name test --target android-23 --abi armeabi-v7a
Android 6.0 is a basic Android platform.
Do you wish to create a custom hardware profile [no]Created AVD 'test' based on Android 6.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
travis_time:end:1030008c:start=1446127538783461373,finish=1446127542625988764,duration=3842527391
[0Ktravis_fold:end:before_script.1
[0Ktravis_fold:start:before_script.2
[0Ktravis_time:start:16b2cef4
[0K$ emulator -avd test -no-skin -no-audio -no-window -no-boot-anim &
travis_time:end:16b2cef4:start=1446127542630405331,finish=1446127542635242867,duration=4837536
[0Ktravis_fold:end:before_script.2
[0Ktravis_fold:start:before_script.3
[0Ktravis_time:start:00e87790
[0K$ android-wait-for-emulator
emulator: WARNING: Increasing RAM size to 1GB
Waiting for emulator to start
Creating filesystem with parameters:
    Size: 576716800
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7040
    Inode size: 256
    Journal blocks: 2200
    Label: 
    Blocks: 140800
    Block groups: 5
    Reserved block group size: 39
Created filesystem with 11/35200 inodes and 4536/140800 blocks
resize2fs 1.42.13 (17-May-2015)
The filesystem is already 140800 (4k) blocks long.  Nothing to do!

Creating filesystem with parameters:
    Size: 69206016
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 4224
    Inode size: 256
    Journal blocks: 1024
    Label: 
    Blocks: 16896
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 11/4224 inodes and 1302/16896 blocks
emulator: UpdateCheck: current version '24.4.1', last version '24.4.1'
Waiting for emulator to start
... (pruned due to character limit)
Waiting for emulator to start
Emulator is ready
travis_time:end:00e87790:start=1446127542639319959,finish=1446127617455640922,duration=74816320963
[0Ktravis_fold:end:before_script.3
[0Ktravis_fold:start:before_script.4
[0Ktravis_time:start:0b2fd946
[0K$ adb shell input keyevent 82 &
travis_time:end:0b2fd946:start=1446127617473299362,finish=1446127617478276750,duration=4977388
[0Ktravis_fold:end:before_script.4
[0Ktravis_time:start:248749b0
[0K$ ./gradlew build connectedCheck --stacktrace
Downloading https://services.gradle.org/distributions/gradle-2.2.1-all.zip
................................................................................
Unzipping /home/travis/.gradle/wrapper/dists/gradle-2.2.1-all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1-all.zip to /home/travis/.gradle/wrapper/dists/gradle-2.2.1-all/6dibv5rcnnqlfbq9klf8imrndn
Set executable permissions for: /home/travis/.gradle/wrapper/dists/gradle-2.2.1-all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1/bin/gradle
Download https://jcenter.bintray.com/com/android/tools/build/gradle/1.3.0/gradle-1.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/gradle-core/1.3.0/gradle-core-1.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder/1.3.0/builder-1.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint/24.3.0/lint-24.3.0.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/5.2.1/proguard-gradle-5.2.1.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-parent/5.2.1/proguard-parent-5.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder-model/1.3.0/builder-model-1.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder-test-api/1.3.0/builder-test-api-1.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/sdklib/24.3.0/sdklib-24.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/sdk-common/24.3.0/sdk-common-24.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/common/24.3.0/common-24.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/manifest-merger/24.3.0/manifest-merger-24.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/ddms/ddmlib/24.3.0/ddmlib-24.3.0.pom
Download https://jcenter.bintray.com/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom
Download https://jcenter.bintray.com/org/sonatype/oss/oss-parent/7/oss-parent-7.pom
Download https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.pom
Download https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm/5.0.3/asm-5.0.3.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-parent/5.0.3/asm-parent-5.0.3.pom
Download https://jcenter.bintray.com/org/ow2/ow2/1.3/ow2-1.3.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.pom
Download https://jcenter.bintray.com/com/android/tools/jack/jack-api/0.9.0/jack-api-0.9.0.pom
Download https://jcenter.bintray.com/com/android/tools/jill/jill-api/0.9.0/jill-api-0.9.0.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint-checks/24.3.0/lint-checks-24.3.0.pom
Download https://jcenter.bintray.com/org/eclipse/jdt/core/compiler/ecj/4.4.2/ecj-4.4.2.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-base/5.2.1/proguard-base-5.2.1.pom
Download https://jcenter.bintray.com/com/android/tools/annotations/24.3.0/annotations-24.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/layoutlib/layoutlib-api/24.3.0/layoutlib-api-24.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/dvlib/24.3.0/dvlib-24.3.0.pom
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.2.4/gson-2.2.4.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/33/commons-parent-33.pom
Download https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-client/4.1.1/httpcomponents-client-4.1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/project/4.1.1/project-4.1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-client/4.1/httpcomponents-client-4.1.pom
Download https://jcenter.bintray.com/com/google/guava/guava/17.0/guava-17.0.pom
Download https://jcenter.bintray.com/com/google/guava/guava-parent/17.0/guava-parent-17.0.pom
Download https://jcenter.bintray.com/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint-api/24.3.0/lint-api-24.3.0.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-analysis/5.0.3/asm-analysis-5.0.3.pom
Download https://jcenter.bintray.com/com/intellij/annotations/12.0/annotations-12.0.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-core/4.1/httpcomponents-core-4.1.pom
Download https://jcenter.bintray.com/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/5/commons-parent-5.pom
Download https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom
Download https://jcenter.bintray.com/commons-codec/commons-codec/1.4/commons-codec-1.4.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/11/commons-parent-11.pom
Download https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.pom
Download https://jcenter.bintray.com/com/android/tools/build/gradle/1.3.0/gradle-1.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/gradle-core/1.3.0/gradle-core-1.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/builder/1.3.0/builder-1.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint/24.3.0/lint-24.3.0.jar
Download https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/5.2.1/proguard-gradle-5.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/build/builder-model/1.3.0/builder-model-1.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/builder-test-api/1.3.0/builder-test-api-1.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/sdklib/24.3.0/sdklib-24.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/sdk-common/24.3.0/sdk-common-24.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/common/24.3.0/common-24.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/manifest-merger/24.3.0/manifest-merger-24.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/ddms/ddmlib/24.3.0/ddmlib-24.3.0.jar
Download https://jcenter.bintray.com/com/squareup/javawriter/2.5.0/javawriter-2.5.0.jar
Download https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.jar
Download https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm/5.0.3/asm-5.0.3.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.jar
Download https://jcenter.bintray.com/com/android/tools/jack/jack-api/0.9.0/jack-api-0.9.0.jar
Download https://jcenter.bintray.com/com/android/tools/jill/jill-api/0.9.0/jill-api-0.9.0.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint-checks/24.3.0/lint-checks-24.3.0.jar
Download https://jcenter.bintray.com/org/eclipse/jdt/core/compiler/ecj/4.4.2/ecj-4.4.2.jar
Download https://jcenter.bintray.com/net/sf/proguard/proguard-base/5.2.1/proguard-base-5.2.1.jar
Download https://jcenter.bintray.com/com/android/tools/annotations/24.3.0/annotations-24.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/layoutlib/layoutlib-api/24.3.0/layoutlib-api-24.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/dvlib/24.3.0/dvlib-24.3.0.jar
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar
Download https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.jar
Download https://jcenter.bintray.com/com/google/guava/guava/17.0/guava-17.0.jar
Download https://jcenter.bintray.com/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint-api/24.3.0/lint-api-24.3.0.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-analysis/5.0.3/asm-analysis-5.0.3.jar
Download https://jcenter.bintray.com/com/intellij/annotations/12.0/annotations-12.0.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.jar
Download https://jcenter.bintray.com/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
Download https://jcenter.bintray.com/commons-codec/commons-codec/1.4/commons-codec-1.4.jar
Download https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.jar
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/0.7.4.201502262128/org.jacoco.agent-0.7.4.201502262128.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.build/0.7.4.201502262128/org.jacoco.build-0.7.4.201502262128.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/0.7.4.201502262128/org.jacoco.agent-0.7.4.201502262128.jar
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72310Library
:app:prepareComAndroidSupportCardviewV72310Library
:app:prepareComAndroidSupportDesign2310Library
:app:prepareComAndroidSupportRecyclerviewV72310Library
:app:prepareComAndroidSupportSupportV42310Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavacNote: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:unzipJacocoAgent
:app:instrumentDebug
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.ant/0.7.4.201502262128/org.jacoco.ant-0.7.4.201502262128.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.core/0.7.4.201502262128/org.jacoco.core-0.7.4.201502262128.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.report/0.7.4.201502262128/org.jacoco.report-0.7.4.201502262128.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-debug-all/5.0.1/asm-debug-all-5.0.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-parent/5.0.1/asm-parent-5.0.1.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.ant/0.7.4.201502262128/org.jacoco.ant-0.7.4.201502262128.jar
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.core/0.7.4.201502262128/org.jacoco.core-0.7.4.201502262128.jar
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.report/0.7.4.201502262128/org.jacoco.report-0.7.4.201502262128.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-debug-all/5.0.1/asm-debug-all-5.0.1.jar
:app:preDexDebug
:app:dexDebug
:app:validateDebugSigning
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug
:app:checkReleaseManifest
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets
:app:generateReleaseResValues
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:preDexRelease
:app:dexRelease
:app:packageRelease
:app:assembleRelease
:app:assemble
:app:compileLint
:app:lint
Ran lint on variant release: 102 issues found
Ran lint on variant debug: 102 issues found
Wrote HTML report to file:/home/travis/build/Longi94/bptf/app/build/outputs/lint-results.html
Wrote XML report to /home/travis/build/Longi94/bptf/app/build/outputs/lint-results.xml
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:processDebugUnitTestJavaRes UP-TO-DATE
:app:compileDebugUnitTestJavaWithJavac UP-TO-DATE
:app:compileDebugUnitTestSources UP-TO-DATE
:app:mockableAndroidJar
:app:assembleDebugUnitTest
:app:testDebugUnitTest
:app:preReleaseUnitTestBuild UP-TO-DATE
:app:prepareReleaseUnitTestDependencies
:app:processReleaseUnitTestJavaRes UP-TO-DATE
:app:compileReleaseUnitTestJavaWithJavac UP-TO-DATE
:app:compileReleaseUnitTestSources UP-TO-DATE
:app:assembleReleaseUnitTest
:app:testReleaseUnitTest
:app:test
:app:check
:app:build
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:processDebugAndroidTestJavaRes UP-TO-DATE
:app:compileDebugAndroidTestJavaWithJavac
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:compileDebugAndroidTestSources
:app:preDexDebugAndroidTest
:app:dexDebugAndroidTest
:app:packageDebugAndroidTest
:app:assembleDebugAndroidTest
:app:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> com.android.builder.testing.api.TestException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:connectedDebugAndroidTest'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: org.gradle.internal.UncheckedException: com.android.builder.testing.api.TestException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:39)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:66)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 47 more
Caused by: com.android.builder.testing.api.TestException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
    at com.android.builder.testing.SimpleTestRunner.runTests(SimpleTestRunner.java:93)
    at com.android.build.gradle.internal.tasks.DeviceProviderInstrumentTestTask.runTests(DeviceProviderInstrumentTestTask.java:112)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
    ... 54 more
Caused by: com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
    at com.android.builder.testing.ConnectedDevice.getDeviceConfig(ConnectedDevice.java:259)
    at com.android.builder.testing.api.DeviceConfigProviderImpl.<init>(DeviceConfigProviderImpl.java:36)
    at com.android.builder.testing.SimpleTestRunner.runTests(SimpleTestRunner.java:91)
    ... 56 more
Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:511)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:388)
    at com.android.ddmlib.Device.executeShellCommand(Device.java:577)
    at com.android.builder.testing.ConnectedDevice.executeShellCommand(ConnectedDevice.java:136)
    at com.android.builder.testing.ConnectedDevice.getDeviceConfig(ConnectedDevice.java:256)
    ... 58 more


BUILD FAILED

Total time: 3 mins 27.125 secs
travis_time:end:248749b0:start=1446127617481908384,finish=1446127825369726746,duration=207887818362
[0K
[31;1mThe command "./gradlew build connectedCheck --stacktrace" exited with 1.[0m

Done. Your build exited with 1.

任何帮助将不胜感激!

在ProbleSlover的建议之后编辑:

删除platform-toolstools行后。似乎构建没有等待模拟器先前启动的时间。现在有很多等待和构建超时,并出现以下错误:

Waiting for emulator to start

Timeout (360 seconds) reached; failed to start emulator
The command "android-wait-for-emulator" failed and exited with 1 during .

Your build has been stopped.

1 个答案:

答案 0 :(得分:9)

简短回答

Android Gradle Plugin的硬编码超时值太低了。

Google将其修复为version 2.0.0-beta3

  

将在2.0.0-beta3。

     

那么我们在build.gradle中放置什么来设置这个超时值?

     

目前它全部附加到android.adbOptions.timeOutInMs。

示例:Google项目Increasing ADB timeoutadding Travis-ci support。它works

之前的回复

您正在禁用启动动画并且android-wait-for-emulator脚本依赖于它,因此默认脚本在仿真器准备好之前退出循环。阅读this great explanation

当脚本被标记为here

时,我写了这篇文章

现在该脚本可以运行,您只需要在此处删除-no-boot-anim

  - emulator -avd test -no-skin -no-audio -no-window &

或者,您可以禁用加速它的启动动画,但是您需要修改脚本,添加您知道足以让仿真器准备好的时间。

有时我会这样做,例如here

# Wait for device ready
function wait-for-device-ready {
    local bootanim=""
    local failcounter=0
    until [[ "$bootanim" =~ "stopped" ]]; do
       bootanim=`adb hell getprop init.svc.bootanim 2>&1`
       echo "$bootanim"
       if [[ "$bootanim" =~ "not found" ]]; then
          let "failcounter += 1"
          if [[ ${failcounter} -gt 30 ]]; then
            echo "Failed to start emulator"
            exit 1
          fi
       fi
       sleep 1
    done
    sleep 30
    adb shell input keyevent 82 &
    sleep 150
    echo "Done"
}

更新:现在我记得,我的回答一般是正确的但是其他原因会产生这个问题,特别是在android-23上,并且你可能在使用我之后仍然看到相同的错误建议,see

我不确定关于android-23案例的其他问题,我需要对其进行调查,但我目前没有使用Travis-ci,只有phew测试。我认为android-23没有预先安装,你需要更新工具和平台工具,有时我看到一些应用程序崩溃,当我的模拟器api 23在家里开始等等。很难知道原因而没有看到它,但是您可以添加日志以尝试查看正在发生的事情,请检查my script

<强> UPDATE2

在android-23上关于此错误打开stackoverflow questionandroid issue

<强> UPDATE3

Cause: Hardcoded and too low timeout=5, line 256

try {
    executeShellCommand("am get-config", receiver, 5, TimeUnit.SECONDS);
    return DeviceConfig.Builder.parse(output);
} catch (Exception e) {
    throw new DeviceException(e);
}

错误可在本地重现:

08:22:53.761 [ERROR] [org.gradle.BuildExceptionReporter]
08:22:53.795 " Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
08:22:53.795 "        at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:511)
08:22:53.795 "        at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:388)
08:22:53.795 "        at com.android.ddmlib.Device.executeShellCommand(Device.java:577)
08:22:53.796 "        at com.android.builder.testing.ConnectedDevice.executeShellCommand(ConnectedDevice.java:136)
08:22:53.796 "        at com.android.builder.testing.ConnectedDevice.getDeviceConfig(ConnectedDevice.java:256) <--------
08:22:53.796 "        ... 78 more

Please star this issue, and read the unity3d workaround

Update4:

您可以使用adb作为解决方法,我测试它适用于Travis

#!/bin/bash

############  ###########  ##########  #########  ########  #######  ######  #####  ####  ###  ##  #
##
##  ACIB SCRIPT
##
############  ###########  ##########  #########  ########  #######  ######  #####  ####  ###  ##  #

# Run android tests
function android-test {
    adb shell input keyevent 82 &
    ./gradlew assembleDebug -PdisablePreDex
    ./gradlew assembleDebugAndroidTest -PdisablePreDex
    adb install app/build/outputs/apk/app-debug.apk
    adb install app/build/outputs/apk/app-debug-androidTest-unaligned.apk
    adb shell pm grant com.google.samples.apps.topeka android.permission.SET_ANIMATION_SCALE
    adb shell am instrument -w  -e numShards 6 -e shardIndex 0 -e package com.google.samples.apps.topeka com.google.samples.apps.topeka.test/android.support.test.runner.AndroidJUnitRunner
    adb shell am instrument -w  -e numShards 6 -e shardIndex 1 -e package com.google.samples.apps.topeka com.google.samples.apps.topeka.test/android.support.test.runner.AndroidJUnitRunner
    adb shell am instrument -w  -e numShards 6 -e shardIndex 2 -e package com.google.samples.apps.topeka com.google.samples.apps.topeka.test/android.support.test.runner.AndroidJUnitRunner
    adb shell am instrument -w  -e numShards 6 -e shardIndex 3 -e package com.google.samples.apps.topeka com.google.samples.apps.topeka.test/android.support.test.runner.AndroidJUnitRunner
    adb shell am instrument -w  -e numShards 6 -e shardIndex 4 -e package com.google.samples.apps.topeka com.google.samples.apps.topeka.test/android.support.test.runner.AndroidJUnitRunner
    adb shell am instrument -w  -e numShards 6 -e shardIndex 5 -e package com.google.samples.apps.topeka com.google.samples.apps.topeka.test/android.support.test.runner.AndroidJUnitRunner
}

我需要修复它,但安装成功,没有超时。