gpt4 book ai didi

Android 测试在 Travis 上失败并出现 ShellCommandUnresponsiveException

转载 作者:IT王子 更新时间:2023-10-28 23:31:23 26 4
gpt4 key购买 nike

对于我们在 Travis 上的 Android 项目,我们在第一次甚至第二次执行拉取请求时看到很多构建失败。但是,如果我们重新启动完全相同的构建足够多次,它最终会通过。

这是失败时错误的样子:

:onebusaway-android:connectedAndroidTest
09:48:14 E/Device: Error during shell execution: null
Unable to install /home/travis/build/OneBusAway/onebusaway-android/onebusaway-android/build/outputs/apk/onebusaway-android-debug.apk
com.android.ddmlib.InstallException
at com.android.ddmlib.Device.installPackages(Device.java:927)
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:105)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:125)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:48)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:513)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:390)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:359)
at com.android.ddmlib.Device.executeShellCommand(Device.java:566)
at com.android.ddmlib.Device.createMultiInstallSession(Device.java:987)
at com.android.ddmlib.Device.installPackages(Device.java:884)
... 9 more
com.android.builder.testing.ConnectedDevice > runTests[test(AVD) - 5.0.1] FAILED
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:108)
null
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:108)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:125)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:48)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.ddmlib.InstallException
at com.android.ddmlib.Device.installPackages(Device.java:927)
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:105)
... 8 more
Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:513)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:390)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:359)
at com.android.ddmlib.Device.executeShellCommand(Device.java:566)
at com.android.ddmlib.Device.createMultiInstallSession(Device.java:987)
at com.android.ddmlib.Device.installPackages(Device.java:884)
... 9 more
:onebusaway-android:connectedAndroidTest FAILED
FAILURE: Build failed with an exception.

我们正在使用 gradlew connectedTest 在 Travis 上的模拟器上运行测试。

这是我们的 .travis.yml:

# Test format changes to this .travis.yml file before submitting a PR with:
# http://lint.travis-ci.org/OneBusAway/onebusaway-android

language: android
jdk: oraclejdk7
# Turn off caching to avoid any caching problems
cache: false
# Use the Travis Container-Based Infrastructure (see #203)
sudo: false
env:
global:
- ANDROID_API_LEVEL=21
- ANDROID_BUILD_TOOLS_VERSION=21.1.2
- ANDROID_ABI=google_apis/armeabi-v7a

android:
components:
- platform-tools
- tools
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
- android-$ANDROID_API_LEVEL
# For Google Maps API v1
- addon-google_apis-google-$ANDROID_API_LEVEL
# Google Play Services
- extra-google-google_play_services
# Support library
- extra-android-support
# Latest artifacts in local repository
- extra-google-m2repository
- extra-android-m2repository
# Specify at least one system image
- sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL

before_script:
# Create and start emulator
- echo no | android create avd --force -n test -t "Google Inc.:Google APIs:"$ANDROID_API_LEVEL --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &

script:
- ./wait_for_emulator
- ./gradlew connectedCheck -PdisablePreDex

# Integration with Gitter (https://gitter.im/OneBusAway/onebusaway-android)
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/493b93a98ed03a010c4c
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: false # default: false

最佳答案

您可以将 Travis 上的环境变量 ADB_INSTALL_TIMEOUT 设置为 8 分钟等值以避免此问题。

例如,在您的 .travis.yml 中:

language: android
jdk: oraclejdk7
# Turn off caching to avoid any caching problems
cache: false
# Use the Travis Container-Based Infrastructure
sudo: false
env:
global:
- ANDROID_API_LEVEL=21
- ANDROID_BUILD_TOOLS_VERSION=21.1.2
- ANDROID_ABI=armeabi-v7a
- ADB_INSTALL_TIMEOUT=8 # minutes (2 minutes by default)

android:
components:
- platform-tools
- tools
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
- android-$ANDROID_API_LEVEL

ShellCommandUnresponsiveExceptionAOSP issue 69735: Ddmlib is too agressive with timeouts in Device.java 相关,如果 ddmlib 没有接收到输入,这会导致它快速超时。上述环境变量在 Travis VM 上延长了这个超时时间。

另外请确保您使用的是最新的 API 级别 SDK 和构建工具(至少是上述版本),因为早期版本不允许设置此环境变量。

请注意,如果您的测试偶尔通过 Travis,这可能只会解决您的问题 - 如果您的构建总是失败,您可能会遇到其他问题。

2016 年 3 月编辑

请注意,如果您仍然看到故障,尤其是在 API 级别 23 模拟器上,则可能是另一个模拟器超时问题导致您出现问题。

要解决这个问题,您需要将 Gradle 插件更新到至少 2.0.0-beta3 - 例如:

dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
}

详情见:

关于Android 测试在 Travis 上失败并出现 ShellCommandUnresponsiveException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28949722/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com