我使用谷歌官方文档中推荐的 Espresso 在小米真机上做 UI 测试,出错,内容如下 : java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=包名.要测试的 Activity 名 } 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 1582721904973 and now the last time the queue went idle was: 1582721914711. If these numbers are the same your activity might be hogging the event queue. at androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:453) at androidx.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:358) at androidx.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:529) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at androidx.test.runner.AndroidJUnit4.run(AndroidJUnit4.java:104) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56) at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:388) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2160)
百度谷歌了一下午
1.确定没有耗时操作
2.确定没有自定义控件
3.确定没有各种形式的 ProgressBar
4.就是一些简单的点击操作
5.关闭了设置中有关动画过渡之类的选项
6.关闭了 MIUI 优化
同样的测试代码在华为手机上运行正常,在小米 8 和红米上却不行
有人遇到过吗?最后是怎么解决的呢?
小米手机的 API 是28
我是Smartisan R1 API26,搞一上午,换华为立马没问题...