問題描述
我似乎無法從命令行獲取 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 APIs 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 for 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/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
和star 問題
你是對的.這不是 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 命令失敗的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!