How to solve this error InvalidElementStateException when testing android app using Appium with Espresso driver?

0

I am using Appium with an Espresso driver to test an Android app. In one of my tests I am getting this error: org.openqa.selenium.InvalidElementStateException: The application is expected to be in idle state in order for Espresso to interact with it. Review the threads dump below to know more on which entity is hogging the events loop ThreadName: main: State: RUNNABLE
in this video the https://www.youtube.com/watch?v=gU9EEUV5n9U there is a solution to this problem using the androidx.test.espresso.idling.CountingIdlingResource But how can I access the CountingIdlingResource in the app code from my Appium test code? can someone get this problem and can give me some code examples, of how to do it?