Espresso测试错误:AppNotIdleException

use*_*803 20 android ui-testing android-espresso

我关闭了开发者选项的所有动画.但是当我尝试点击其中一个按钮时,我仍然会遇到此异常.

我的应用确实是活跃的,并没有完全闲置,但我无法改变它.

android.support.test.espresso.AppNotIdleException: Looped for 6930
iterations over 60 SECONDS. The following Idle Conditions failed .
 at dalvik.system.VMStack.getThreadStackTrace(Native Method)
 at java.lang.Thread.getStackTrace(Thread.java:580)
 at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:92)
 at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56)
 at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
 at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
 at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
Run Code Online (Sandbox Code Playgroud)

小智 5

过去几天我一直在为这个问题苦苦挣扎。
这是我用来识别“违规者”的方法:

private void dumpThreads() {
    int activeCount = Thread.activeCount();
    Thread[] threads = new Thread[activeCount];
    Thread.enumerate(threads);
    for (Thread thread : threads) {
        System.err.println(thread.getName() + ": " + thread.getState());
        for (StackTraceElement stackTraceElement : thread.getStackTrace()) {
            System.err.println("\t" + stackTraceElement);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

就我而言,Facebook SDK 使用 AsyncTask 线程池。

  • 您还可以在应用程序挂起时暂停应用程序(在调试模式下),并查看所有处于“运行”状态的 AsyncTasks。 (2认同)

W4R*_*0CK 1

根据MaciejG\xc3\xb3rski 对类似问题的回答

\n\n
\n

这是我的应用程序代码中的一个错误,SwipeRefreshLayout它本身会无限期地进行动画处理。由于此组件中存在错误,\n 甚至未显示刷新状态。

\n
\n