I'm developing a small set of instrumented tests using JUnit and Espresso to automate the testing process of my activities and fragments, but I'm having some crashes in some devices.
The test suite runs fine on the Pixel 6 with API 31 and on the Pixel 3 with API 30. I chose those devices/APIs because I intend to run these tests in the Firebase Test Lab in the near future.
Running the same test suite in the Pixel 2 with API 29 throws the following exception while opening the activity on the first test:
W/Binder: Caught a RuntimeException from the binder stub implementation.
java.lang.SecurityException: Calling from not trusted UID!
at android.app.UiAutomationConnection.throwIfCalledByNotTrustedUidLocked(UiAutomationConnection.java:520)
at android.app.UiAutomationConnection.shutdown(UiAutomationConnection.java:424)
at android.app.IUiAutomationConnection$Stub.onTransact(IUiAutomationConnection.java:390)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)
Outgoing transactions from this process must be FLAG_ONEWAY
java.lang.Throwable
at android.os.BinderProxy.transact(BinderProxy.java:480)
at android.app.IInstrumentationWatcher$Stub$Proxy.instrumentationFinished(IInstrumentationWatcher.java:205)
at com.android.server.am.InstrumentationReporter$MyThread.run(InstrumentationReporter.java:86)
Debugging my tests I can see that the error is thrown from the super.onCreate(savedInstanceState)
line (first line of the activity's onCreate
method). However, running the application in normal mode is working fine on that same device/API.
Has anyone seen this before? Am I missing something in my activity to make this work?