Is there a way to bypass espresso with Lollipop (Android 21)?

Attempting to run a test using a UI code using espresso (i.e. GoogleInstrumentationTestRunner ) on a Nexus 7 with Lollipop gives the following error:

java.lang.IllegalStateException: This message cannot be recycled because it is still in use. at android.os.Message.recycle(Message.java:279) at com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:468) at com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:337) at com.google.android.apps.common.testing.ui.espresso.ViewInteraction$1.run(ViewInteraction.java:94) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

This was probably a known problem for several months , but since it has not been fixed since January 8, it is not known whether there will be an official correction.

There is a comment in the discussion that says

Just removing message.recycle (); seems to fix it ...

Is this a valid workaround? If not, what would be the correct correction?

+6
source share
1 answer

UPDATE: use Espresso 2.0 to support Lollipop https://code.google.com/p/android-test-kit/wiki/EspressoSetupInstructions

Yes, if you delete "message.recycle ();" and rebuild, it will solve this problem.

The Espresso team announced on GTAC that the next release of Espresso will be on AOSP for too long. Watch the video here: https://www.youtube.com/watch?v=aHcmsK9jfGU

(I was the original poster of this question that you referred to)

UPDATE:

 // you will want to keep it for older API versions if ( SDK_INT < 21 ){ message.recycle(); } 

+5
source

Source: https://habr.com/ru/post/978636/


All Articles