API 23 Google API 模拟器映像 (armeabi-v7a) 上的 Gradle 命令失败 [英] Gradle commands fail on API 23 Google API emulator image (armeabi-v7a)
问题描述
我似乎无法从命令行获取 Gradle 命令以使用 API 23 Google API 模拟器映像 (Google APIs ARM (armeabi-v7a)
) - 我总是得到一个 com.android.ddmlib.ShellCommandUnresponsiveException
.
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
.
重现步骤:
- 使用 API 23 创建 AVD
Google API ARM (armeabi-v7a)
- 克隆 https://github.com/googlemaps/android-maps-utils(或使用您自己的项目)
- 从命令行运行
gradlew installDebug
- Create an AVD with API 23
Google APIs ARM (armeabi-v7a)
- Clone https://github.com/googlemaps/android-maps-utils (or use your own project)
- Run
gradlew installDebug
from the command line
你会看到:
:demo:assembleDebug:demo:installDebug 失败
:demo:assembleDebug :demo:installDebug FAILED
FAILURE:构建失败,出现异常.
FAILURE: Build failed with an exception.
- 出了什么问题:
任务 ':demo:installDebug' 执行失败.com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
Execution failed for task ':demo:installDebug'. com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
如果你运行 gradlew connectedCheck
你会看到类似的错误:
If you run gradlew connectedCheck
you'll see a similar error:
- 出了什么问题:任务 ':library:connectedDebugAndroidTest' 执行失败.com.android.builder.testing.api.TestException:com.android.builder.testing.api.DeviceException:com.android.ddmlib.ShellCommandUnresponsiveException
我可以从 Android Studio (1.4) 安装/运行项目和测试,没有任何问题.
I can install/run the project and tests from Android Studio (1.4) without any problems.
Gradle 命令似乎在 API 21 Google API 模拟器映像上从命令行运行良好.
Gradle commands seem to run fine on the API 21 Google API emulator image from the command line.
以下是 Travis 上的 API 23 Google API 模拟器图像失败示例:
Here is an example failure on Travis for API 23 Google API emulator image:
https://travis-ci.org/barbeau/android-maps-utils/builds/83233500
...以及使用 API 21 Google API 模拟器映像时成功构建的示例:
...and an example successful build when using the API 21 Google API emulator image:
https://travis-ci.org/barbeau/android-maps-utils/builds/83234555
这两个版本的唯一区别是 Google API 模拟器 API 级别为 23 与 21:
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/a5eecd7e7a4fc8904feee一个>
https://github.com/barbeau/android-maps-utils/commit/a5eecd7e7a4fc899ecd5eaeae6826414fefeae70
编辑
我已在此处针对此问题打开了 AOSP 问题:
I've opened an AOSP issue here on this problem:
https://code.google.com/p/android/issues/detail?id=190200
推荐答案
简短回答
Android Gradle 插件的硬编码超时值太低.
Android Gradle Plugin had a hardcoded timeout value that was too low.
Google 在 2.0.0-beta3 版:
将在 2.0.0-beta3 中.
Will be in 2.0.0-beta3.
那么我们在 build.gradle 中放什么来设置这个超时值?
So what do we put in build.gradle to set this timeout value?
目前它都附加到 android.adbOptions.timeOutInMs.
Currently it's all attached to android.adbOptions.timeOutInMs.
示例:Google 项目 增加 ADB 超时 和 添加 Travis-ci 支持.它有效!
Sample: Google project Increasing ADB timeout and adding Travis-ci support. It works!.
之前的回复
这是 这里已经报告了同样的问题
阅读unity3 开发人员的解决方法 关于这里的硬编码和低超时
Read the workaround from the unity3 developer about the hardcoded and low timeout here
和星级 问题
你说得对.这不是 Travis-ci 问题,要重现它,您只需要创建一个 armeabi-v7a 模拟器并尝试通过 gradle 命令在本地安装任何应用程序.
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.
更多信息这里是我回答的更新 3
更新:
您可以使用 adb 避免 installVariant
任务和此问题:
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
它有效:
...
: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:..
这篇关于API 23 Google API 模拟器映像 (armeabi-v7a) 上的 Gradle 命令失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!