Skip to content

Android - java.lang.RuntimeException: java.util.concurrent.ExecutionException: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [com.wix.detox.reactnative.idlingresources.network.NetworkIdlingResource] to become idle timed out #4880

@dhairyasenjaliya

Description

@dhairyasenjaliya

Did you test using the latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test fail and you're not sure why?

  • I have read the troubleshooting guide and it didn't help me.

What happened?

Detox on Android is consistently failing because the app never reaches an “idle” state, which Detox requires before running any test actions.

Specifically, Detox uses Espresso’s NetworkIdlingResource to detect whether the app has finished all background network activity. On React Native 0.79.x with Detox 20.x and Android emulators API 15–16, this idling resource never becomes idle, even when:

  • the app appears fully loaded on screen
  • no visible crash occurs
  • UI is rendered
  • the JavaScript bundle loads successfully

Detox successfully connects to the instrumentation

This results in Detox thinking the app is “busy forever,” causing:

  • the Detox session to hang at startup
  • Detox to never execute any actual test commands
  • Espresso to terminate instrumentation due to timeout
  • Detox to interpret the failure as an app crash

What was the expected behaviour?

  • Detox should continue tests same as iOS without any network error

Help us reproduce this issue!

React Native version: 0.79.4
Detox version: 20.40.2 / 20.46.0

nothing special upgraded from 0.60 to 0.79, and detox used to work onthe same version after a couple of months, just re-test again at that time, this error occurs on Android only

In what environment did this happen?

Detox version: 20.40.2 / 20.46.0
React Native version: 0.79.4
Has Fabric (React Native's new rendering system) enabled: (yes/no)
Node version: 20.14.0
Device model: emulator
Android version: 16.0 / 15.0
Test-runner (select one): jest

Detox logs

Detox logs
  The app has crashed. See the details below:

    @Thread detox.primary(78):
    java.lang.RuntimeException: java.util.concurrent.ExecutionException: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [com.wix.detox.reactnative.idlingresources.network.NetworkIdlingResource] to become idle timed out
    	at androidx.test.espresso.Espresso.onIdle(Espresso.java:357)
    	at com.wix.detox.TestEngineFacade.awaitIdle(TestEngineFacade.kt:12)
    	at com.wix.detox.adapters.server.ReadyActionHandler.handle(DetoxActionHandlers.kt:27)
    	at com.wix.detox.DetoxMain$setupActionHandlers$SynchronizedActionHandler.handle(DetoxMain.kt:78)
    	at com.wix.detox.adapters.server.ActionsExecutor.executeAction$lambda$2$lambda$1(DetoxActionsDispatcher.kt:76)
    	at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$GVbB7LHtBHxNHGbgYnHJ6YrwCqs(Unknown Source:0)
    	at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
    	at android.os.Handler.handleCallback(Handler.java:959)
    	at android.os.Handler.dispatchMessage(Handler.java:100)
    	at android.os.Looper.loopOnce(Looper.java:232)
    	at android.os.Looper.loop(Looper.java:317)
    	at com.wix.detox.adapters.server.ActionsExecutor._init_$lambda$0(DetoxActionsDispatcher.kt:62)
    	at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$xlgL0CQim6vNM0wWEqM8JIDgZUE(Unknown Source:0)
    	at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
    	at java.lang.Thread.run(Thread.java:1012)
    Caused by: java.util.concurrent.ExecutionException: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [com.wix.detox.reactnative.idlingresources.network.NetworkIdlingResource] to become idle timed out
    	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    	at java.util.concurrent.FutureTask.get(FutureTask.java:191)
    	at androidx.test.espresso.Espresso.onIdle(Espresso.java:349)
    	... 14 more
    Caused by: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [com.wix.detox.reactnative.idlingresources.network.NetworkIdlingResource] to become idle timed out
    	at androidx.test.espresso.IdlingPolicy.handleTimeout(IdlingPolicy.java:63)
    	at androidx.test.espresso.base.UiControllerImpl$5.resourcesHaveTimedOut(UiControllerImpl.java:420)
    	at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleTimeout(IdlingResourceRegistry.java:533)
    	at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleMessage(IdlingResourceRegistry.java:466)
    	at android.os.Handler.dispatchMessage(Handler.java:103)
    	at androidx.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:156)
    	at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:510)
    	at androidx.test.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:433)
    	at androidx.test.espresso.Espresso.lambda$onIdle$2(Espresso.java:340)
    	at androidx.test.espresso.Espresso$$ExternalSyntheticLambda1.call(D8$$SyntheticClass:0)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    	at android.os.Handler.handleCallback(Handler.java:959)
    	at android.os.Handler.dispatchMessage(Handler.java:100)
    	at android.os.Looper.loopOnce(Looper.java:232)
    	at android.os.Looper.loop(Looper.java:317)
    	at android.app.ActivityThread.main(ActivityThread.java:8705)
    	at java.lang.reflect.Method.invoke(Native Method)
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)

Device logs

Device logs
paste your device.log here!

More data, please!

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions