简体   繁体   English

Android Instrumentation Test在Travis CI AVD上失败,但在本地模拟器上工作

[英]Android Instrumentation Test fail on Travis CI AVD but work on local emulator

If i run instrumentation tests on my local emulator they run 10 out of 10 times perfectly but when I try to run the same tests on an AVD in Travis CI, I randomly get 如果我在本地模拟器上运行仪器测试,则它们可以完美运行10次,其中10次完美运行,但是当我尝试在Travis CI的AVD上运行相同的测试时,我会随机得到

FAILED java.lang.RuntimeException: Could not launch intent Intent { } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was xxxxxxx and now the last time the queue went idle was: xxxxxxxxx. If these numbers are the same your activity might be hogging the event queue.

I have tried removing all progress bars and everything but still its an issue that is only happening randomly and on Travis. 我尝试删除所有进度条和所有内容,但仍然是随机和在Travis上发生的问题。 My travis.yml looks like this: 我的travis.yml看起来像这样:

env:
  global:
    - ANDROID_TARGET=android-19
    - ANDROID_ABI=armeabi-v7a
  before_script:
      - android list targets
      - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
      - emulator -avd test -no-skin -no-audio -no-window -no-boot-anim &
      - android-wait-for-emulator
      - adb shell input keyevent 82 &
    script:
      - ./gradlew jacocoTestReport assembleAndroidTest connectedCheck zipalignRelease

If you want to use android-wait-for-emulator script, please remove the -no-boot-anim option it depends on to detect when emulator is ready. 如果要使用android-wait-for-emulator脚本,请删除 -no-boot-anim选项,该选项取决于检测模拟器准备就绪的时间。

Alternatively, replace the android-wait-for-emulator script by a fixed sleep time like this: 另外,更换android-wait-for-emulator由一个固定的脚本睡眠时间是这样的:

  - sleep 300
  - adb shell input keyevent 82 &

You need to choose the sleep time based on each API boot duration. 您需要根据每个API引导持续时间选择睡眠时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Travis CI上的Android模拟器显示com.android.builder.testing.ConnectedDevice> hasTests [test(AVD) - 4.4.2] FAILED即使测试存在 - Android emulator on Travis CI showing com.android.builder.testing.ConnectedDevice > hasTests[test(AVD) - 4.4.2] FAILED even though tests present 有没有办法在Travis CI构建中启动Android模拟器? - Is there a way to start android emulator in Travis CI build? Travis CI Android仿真器中的EACCES(权限被拒绝) - EACCES (Permission denied) in Travis CI Android Emulator 授权Android Instrumentation Test可以在模拟器上进行根访问 - Authorize Android Instrumentation Test for Root Access on Emulator 在Travis CI中运行Android JUnit测试 - Running Android JUnit test in Travis CI 特拉维斯CI仍然没有通过Espresso测试 - Android - Travis CI still failing with Espresso test - Android 运行仪器测试离子Gitlab CI时出现不兼容的AVD错误 - Getting incompatible AVD error while running instrumentation test ion Gitlab CI 在Travis CI上执行检测测试时出现AssertionFailedWithCauseError - AssertionFailedWithCauseError when executing instrumentation tests on Travis CI 在Travis CI中构建apk失败,因为“Instrumentation failed” - Build apk in Travis CI failed for “Instrumentation failed” JUnit 本地测试 - Android 上下文“未注册检测!” - JUnit Local Test - Android Context 'No instrumentation registered!'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM