java.lang.RuntimeException:无法仅在api 28(android 9)上的emulator上启动intent intent
在浓缩咖啡测试中看到此异常:java.lang.RuntimeException:无法仅在api 28(android 9)上的emulator上启动intent intent,android,kotlin,android-espresso,Android,Kotlin,Android Espresso,在浓缩咖啡测试中看到此异常: java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=/.root.presentationcomponent.implementation.RootActivity } within 45000 milliseconds. Perhaps the main thread has not gone
java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=/.root.presentationcomponent.implementation.RootActivity } within 45000 milliseconds.
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 1603447989081 and now the last time the queue went idle was: 1603447994446. If these numbers are the same your activity might be hogging the event queue.
at androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:490)
at androidx.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:358)
在具有API23、25、27、28的模拟器上运行此测试,在API28上只会100%失败。页面浏览了所有其他StackOverflow,大多数人说解决方案是禁用已经完成的动画
测试:
有人对为什么会发生这种情况有其他建议吗?我们在不同页面上的不同测试中执行此行为,没有问题
@Test
fun test() {
masterRobot.apply {
// conditions set here
}
// When app is launched
activityRule.launchActivity(null)
// When clicked retry
onView(ViewMatchers.withId())
.perform(ScrollToAction())
.perform(click())
// When the user clicks positive
onView(ViewMatchers.withId())
.perform(ScrollToAction())
.perform(ViewActions.click())
// Then, dialog
Espresso.onView(ViewMatchers.withText())
.inRoot(RootMatchers.isDialog())
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
// When, set succeed, click OK and then click done.
Espresso.onView(ViewMatchers.withText(R.string.DialogOk))
.perform(ViewActions.click())
addActivityResultVerifier(true)
Espresso.onView(ViewMatchers.withId())
.perform(ViewActions.click())
// Then, app quits with successful activity result
Espresso.onIdle()
assertTrue(activityRule.activity.isFinishing || activityRule.activity.isDestroyed)
// When app is finished and launched again
activityRule.finishActivity()
activityRule.launchActivity(null)
// success text
Espresso.onView(ViewMatchers.withId())
.check(ViewAssertions.matches(ViewMatchers.withText()))
}