Skip to content Skip to sidebar Skip to footer

Travis-ci Build Keeps Failing With Shellcommandunresponsiveexception

I'm trying to get travis-ci to work with my android application. If I only execute assembleDebug it works fine. But I want to run tests too and generate code coverage. This is the

Solution 1:

Short answer

Android Gradle Plugin had a hardcoded timeout value that was too low.

Google fixed it in version 2.0.0-beta3:

Will be in 2.0.0-beta3.

So what do we put in build.gradle to set this timeout value?

Currently it's all attached to android.adbOptions.timeOutInMs.

Sample: Google project Increasing ADB timeout and adding Travis-ci support. It works!


Previous response

You are disabling the boot anim and the android-wait-for-emulator script depends on it, so the default script exits from the loop before the emulator is ready. Read this great explanation.

I wrote about it when the script was bugged here

Now the script works and you only need to delete -no-boot-anim here:

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

Alternatively, you can disable the boot animation that speeds up it, but you need to modify the script adding the time you know is enough for your emulator to be ready.

Sometimes I do it, like here

# Wait for device readyfunction 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" ]]; thenlet"failcounter += 1"if [[ ${failcounter} -gt 30 ]]; thenecho"Failed to start emulator"exit 1
          fifisleep 1
    donesleep 30
    adb shell input keyevent 82 &
    sleep 150
    echo"Done"
}

Update: Now that I remember, my response is correct in general but other causes produce this issue, especially on android-23, and it is possible that you still see the same error after using my suggestion, see.

I'm not sure about the other issue regarding the android-23 case, I need to investigate it, but I'm not currently using Travis-ci, only a phew tests. I think android-23 is not preinstalled and you need update tools and platform-tools, sometimes I see some apps crash when my emulator api 23 starts at home, etc. It's hard to know the reason without seeing it, but you can add logs to try to see what is happening, inspect my script for that.

Update2:

Open stackoverflow question and android issue about this error on android-23.

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) {
    thrownew DeviceException(e);
}

Error is reproducible locally:

08:22:53.761 [ERROR] [org.gradle.BuildExceptionReporter]08:22:53.795 " Caused by: com.android.ddmlib.ShellCommandUnresponsiveException08: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:

You can use adb as a work around, I tested it works on Travis:

#!/bin/bash############  ###########  ##########  #########  ########  #######  ######  #####  ####  ###  ##  #####  ACIB SCRIPT##############  ###########  ##########  #########  ########  #######  ######  #####  ####  ###  ##  ## Run android testsfunction 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
}

I need to fix it, but the installation is successful, no timeouts.

Post a Comment for "Travis-ci Build Keeps Failing With Shellcommandunresponsiveexception"