Android tests fail on Travis with ShellCommandUnresponsiveException

别等时光非礼了梦想. 提交于 2019-11-27 20:35:46
Sean Barbeau

You can set the environmental variable ADB_INSTALL_TIMEOUT on Travis to a value such as 8 minutes to avoid this problem.

For example, in your .travis.yml:

language: android
jdk: oraclejdk7
# Turn off caching to avoid any caching problems
cache: false
# Use the Travis Container-Based Infrastructure
sudo: false
env:
  global:
    - ANDROID_API_LEVEL=21
    - ANDROID_BUILD_TOOLS_VERSION=21.1.2
    - ANDROID_ABI=armeabi-v7a
    - ADB_INSTALL_TIMEOUT=8 # minutes (2 minutes by default)

android:
  components:
    - platform-tools
    - tools
    - build-tools-$ANDROID_BUILD_TOOLS_VERSION
    - android-$ANDROID_API_LEVEL

The ShellCommandUnresponsiveException is related to AOSP issue 69735: Ddmlib is too agressive with timeouts in Device.java, which causes ddmlib to timeout quickly if it doesn't receive input. The above environmental variable extends this timeout period on the Travis VM.

Also please be sure you're using the latest API level SDK and Build tools (at least the version above), since earlier versions don't allow setting this environmental variable.

Note that this may only resolve your problem if your tests occasionally pass on Travis - if your build always fails you may have other problems going on.

EDIT March 2016

Note that if you're still seeing failures, especially on API Level 23 emulator, there is another emulator timeout issue that may be causing you problems.

To get around this, you'll need to update your Gradle plugin to at least 2.0.0-beta3 - for example:

dependencies {
    classpath 'com.android.tools.build:gradle:2.0.0-beta5'
}

For details see:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!