13

I can't seem to get Gradle commands from the command line to work with the API 23 Google API emulator image (Google APIs ARM (armeabi-v7a)) - I always get a com.android.ddmlib.ShellCommandUnresponsiveException.

Steps to reproduce:

  1. Create an AVD with API 23 Google APIs ARM (armeabi-v7a)
  2. Clone https://github.com/googlemaps/android-maps-utils (or use your own project)
  3. Run gradlew installDebug from the command line

You'll see:

:demo:assembleDebug :demo:installDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:

Execution failed for task ':demo:installDebug'. com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException

If you run gradlew connectedCheck you'll see a similar error:

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

I can install/run the project and tests from Android Studio (1.4) without any problems.

Gradle commands seem to run fine on the API 21 Google API emulator image from the command line.

Here is an example failure on Travis for API 23 Google API emulator image:

https://travis-ci.org/barbeau/android-maps-utils/builds/83233500

...and an example successful build when using the API 21 Google API emulator image:

https://travis-ci.org/barbeau/android-maps-utils/builds/83234555

The only difference between the two builds is the Google API emulator API level of 23 vs. 21:

https://github.com/barbeau/android-maps-utils/commit/a5eecd7e7a4fc899ecd5eaeae6826414fefeae70

EDIT

I've opened an AOSP issue here on this problem:

https://code.google.com/p/android/issues/detail?id=190200

Sean Barbeau
  • 11,496
  • 8
  • 58
  • 111
  • I have the same problem. Quite frustrating. – Brian Cunnie Oct 14 '15 at 20:55
  • @BrianCunnie agreed - I plan to open an AOSP issue about this, just havne't found the time. Also, FYI - apparently the API Level 22 emulator is messed up too - https://code.google.com/p/android/issues/detail?id=176348&thanks=176348&ts=1433887196. – Sean Barbeau Oct 15 '15 at 13:25
  • Ok, just opened an AOSP issue here - https://code.google.com/p/android/issues/detail?id=190200. – Sean Barbeau Oct 15 '15 at 14:25
  • Did you reproduce it locally? I followed your steps now and it works on my machine. Probably will be solved on Travis-ci after they update their VM, normally newest emulator not preinstalled fails before that https://github.com/travis-ci/travis-cookbooks/blob/master/community-cookbooks/android-sdk/attributes/default.rb – albodelu Nov 06 '15 at 18:32
  • Yes, I reproduced it locally at the time. I'll try again now and see if it works. – Sean Barbeau Nov 06 '15 at 20:44
  • 1
    Just followed steps again (using `Google APIs ARM EAMI v7a System Image` version `Rev. 7` in SDK Manager) and I can still reproduce this locally on a Windows 7 Enterprise machine. `gradlew installDebug` fails from command line with `com.android.ddmlib.ShellCommandUnresponsiveException`. Interestingly, trying to install from Android Studio resulted in the emulator "power-cycling" - haven't seen that before. – Sean Barbeau Nov 06 '15 at 21:04
  • 1
    Sorry, you are right, I reproduced it yesterday locally, I'm going to try to solve it now if possible. – albodelu Nov 07 '15 at 03:41
  • 1
    Another hardcoded and restrictive timeout like this one we talked about months ago lol https://code.google.com/p/android/issues/detail?id=69735 – albodelu Nov 07 '15 at 09:14

1 Answers1

9

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

It's the same issue that has been reported here

Read the workaround from the unity3 developer about the hardcoded and low timeout here

and star the issue

You are right. It's not a Travis-ci issue, to reproduce it, you only need to create an armeabi-v7a emulator and try to install any app locally from gradle command.

Further information here, the update3 of my answer

Update:

You can avoid the installVariant tasks and this issue using adb:

./gradlew clean
./gradlew assembleDebug
./gradlew assembleDebugAndroidTest
adb install app/build/outputs/apk/app-debug.apk
adb install app/build/outputs/apk/app-debug-androidTest-unaligned.apk
adb shell am instrument -w com.google.samples.apps.topeka.test/android.support.test.runner.AndroidJUnitRunner

It works:

...
:app:assembleDebugAndroidTest

BUILD SUCCESSFUL
Total time: 19.787 secs
2413 KB/s (4204090 bytes in 1.701s)
    pkg: /data/local/tmp/app-debug.apk
Success
1984 KB/s (1058902 bytes in 0.521s)
    pkg: /data/local/tmp/app-debug-androidTest-unaligned.apk
Success

com.google.samples.apps.topeka.activity.SignInActivityTest:.
com.google.samples.apps.topeka.activity.quiz.EntertainmentQuizTest:.
com.google.samples.apps.topeka.activity.quiz.GeneralKnowledgeQuizTest:..
albodelu
  • 7,931
  • 7
  • 41
  • 84