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?
source share