Gradle task createDebugCoverageReport on TeamCity fails with exception ShellCommandUnresponsiveException
<p>I'm running Jacoco's <code>createDebugCoverageReport</code> task for an Android project within Docker on TeamCity for continuous integration. Even before <code>createDebugCoverageReport</code> is executed, the build fails at task <code>connectedDebugAndroidTest</code> with exception of <code>com.android.ddmlib.ShellCommandUnresponsiveException</code></p>

<p>log:</p>

<pre><code>[21:17:31][Step 3/4] :app:validateDebugSigning
[21:17:31][Step 3/4] :app:packageDebugAndroidTest
[21:17:31][Step 3/4] :app:assembleDebugAndroidTest
[21:17:41][Step 3/4] :app:connectedDebugAndroidTest FAILED
[21:17:41][Step 3/4] 
[21:17:41][Step 3/4] FAILURE: Build failed with an exception.
[21:17:41][Step 3/4] 
[21:17:41][Step 3/4] * What went wrong:
[21:17:41][Step 3/4] Execution failed for task ':app:connectedDebugAndroidTest'.
[21:17:41][Step 3/4] &gt; com.android.builder.testing.api.TestException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
[21:17:41][Step 3/4] 
[21:17:41][Step 3/4] * Try:
[21:17:41][Step 3/4] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[21:17:41][Step 3/4] 
[21:17:41][Step 3/4] BUILD FAILED
[21:17:41][Step 3/4] 
[21:17:41][Step 3/4] Total time: 1 mins 7.214 secs
</code></pre>

<p>I found a <a href="https://stackoverflow.com/questions/28949722/android-tests-fail-on-travis-with-shellcommandunresponsiveexception">workaround on SO</a> for similar problem on Travis but solution is not applicable to TeamCity.</p>