Attempting to run a test with UI-related 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 has apparently been a known issue for several months but since there have been no commits since January 8, it is unknown whether there will be an official fix.
There is a comment in the discussion thread that states
Just removing message.recycle(); seems to fix it...
Is this a valid workaround? If not, what would the correct fix be?
UPDATE: Use Espresso 2.0 for Lollipop support https://code.google.com/p/android-test-kit/wiki/EspressoSetupInstructions
Yes, if you remove "message.recycle(); " and rebuild it will solve that problem.
The Espresso team announced at GTAC that the next release of Espresso will be in AOSP before too long. See video here: https://www.youtube.com/watch?v=aHcmsK9jfGU
( I was the original poster of that issue you referenced )
UPDATE:
// you will want to keep it for older API versions
if ( SDK_INT < 21 ){
message.recycle();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With