如果我在我的本地模拟器上运行仪器测试,它们会完美地运行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.
我已经尝试删除所有进度条和所有内容但仍然只是随机发生在Travis上的问题。 我的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
答案 0 :(得分:0)
如果您想使用android-wait-for-emulator
脚本,请remove使用-no-boot-anim
选项depends on来检测仿真器何时就绪。
或者,将android-wait-for-emulator
脚本替换为固定的sleep time,如下所示:
- sleep 300
- adb shell input keyevent 82 &
您需要根据每个API启动持续时间选择睡眠时间。