[英]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.