我似乎无法从命令行获取 Gradle 命令以使用 API 23 Google API 模拟器图像(Google APIs ARM (armeabi-v7a)
)——我总是得到一个com.android.ddmlib.ShellCommandUnresponsiveException
.
重现步骤:
- 使用 API 23 创建 AVD
Google APIs ARM (armeabi-v7a)
- 克隆https://github.com/googlemaps/android-maps-utils (或使用您自己的项目)
- 从命令行运行
gradlew installDebug
你会看到:
: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
如果您运行 gradlew connectedCheck
,您会看到类似的错误:
- 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
我可以从 Android Studio (1.4) 安装/运行项目和测试,没有任何问题。
Gradle 命令似乎在命令行的 API 21 Google API 模拟器图像上运行良好。
这是 Travis for API 23 Google API 模拟器图像的失败示例:
https://travis-ci.org/barbeau/android-maps-utils/builds/83233500
...以及使用 API 21 Google API 模拟器图像成功构建的示例:
https://travis-ci.org/barbeau/android-maps-utils/builds/83234555
两个构建之间的唯一区别是 Google API 模拟器 API 级别为 23 与 21:
https://github.com/barbeau/android-maps-utils/commit/a5eecd7e7a4fc899ecd5eaeae6826414fefeae70
编辑
我已经在此处针对此问题打开了一个 AOSP 问题:
最佳答案
简答
Android Gradle 插件的硬编码超时值太低。
Google 在 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.
示例:Google 项目 Increasing ADB timeout和 adding Travis-ci support .它works !
之前的回复
这是same issue that has been reported here
阅读workaround from the unity3 developer关于这里的硬编码和低超时
和星 the issue
你是对的。这不是 Travis-ci 问题,要重现它,您只需要创建一个 armeabi-v7a 模拟器并尝试从 gradle 命令在本地安装任何应用程序。
更多信息 here, the update3 of my answer
更新:
您可以使用 adb 避免 installVariant
任务和这个问题:
./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
有效:
...
: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:..
关于android - Gradle 命令在 API 23 Google API 模拟器图像 (armeabi-v7a) 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32952413/