V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
lixyz
V2EX  ›  Android

使用 Espresso 在小米真机上做 UI 测试失败,有人遇到过吗?

  •  
  •   lixyz · 2020-02-26 21:08:15 +08:00 · 3126 次点击
    这是一个创建于 1520 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用 Espresso 在小米真机上做测试,出错,内容如下 : 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 和红米上却不行

    有人遇到过吗?最后是怎么解决的呢?

    2 条回复    2020-02-26 21:34:48 +08:00
    1mi8delaowang
        1
    1mi8delaowang  
       2020-02-26 21:17:15 +08:00
    是 api27 的手机? 是的话就手动打开悬浮框权限试试看吧
    lixyz
        2
    lixyz  
    OP
       2020-02-26 21:34:48 +08:00
    @1mi8delaowang 是 Android 9,API 28
    开了权限也不行
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3526 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 04:53 · PVG 12:53 · LAX 21:53 · JFK 00:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.