android-test: Espresso throws NoSuchMethodError when testing with AccessibilityChecks enabled
Description
java.lang.NoSuchMethodError: com.google.android.apps.common.testing.accessibility.framework.integrations.espresso.AccessibilityValidator.checkAndReturnResults(Landroid/view/View;)Lcom/google/common/collect/ImmutableList;
at androidx.test.espresso.accessibility.AccessibilityChecks$2.check(AccessibilityChecks.java:65)
at androidx.test.espresso.action.ViewActions$1.perform(ViewActions.java:130)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:366)
at androidx.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:255)
at androidx.test.espresso.ViewInteraction.access$100(ViewInteraction.java:65)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:158)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:155)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at org.robolectric.shadows.ShadowLegacyMessageQueue.dispatchMessage(ShadowLegacyMessageQueue.java:157)
at org.robolectric.shadows.ShadowLegacyMessageQueue.access$200(ShadowLegacyMessageQueue.java:42)
at org.robolectric.shadows.ShadowLegacyMessageQueue$1.run(ShadowLegacyMessageQueue.java:135)
at org.robolectric.util.Scheduler.runOrQueueRunnable(Scheduler.java:359)
at org.robolectric.util.Scheduler.postDelayed(Scheduler.java:163)
at org.robolectric.util.Scheduler.postDelayed(Scheduler.java:152)
at org.robolectric.shadows.ShadowLegacyMessageQueue.enqueueMessage(ShadowLegacyMessageQueue.java:142)
at android.os.MessageQueue.enqueueMessage(MessageQueue.java)
at android.os.Handler.enqueueMessage(Handler.java:745)
at android.os.Handler.sendMessageAtTime(Handler.java:697)
at android.os.Handler.sendMessageDelayed(Handler.java:667)
at android.os.Handler.post(Handler.java:395)
at androidx.test.espresso.base.BaseLayerModule$1.execute(BaseLayerModule.java:92)
at androidx.test.espresso.ViewInteraction.postAsynchronouslyOnUiThread(ViewInteraction.java:312)
at androidx.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:166)
at androidx.test.espresso.ViewInteraction.perform(ViewInteraction.java:119)
at jp.cldh.signin.ui.SignInFragmentTest$testStartTwitterSignIn$1.perform(SignInFragmentTest.kt:80)
at jp.cldh.signin.ui.SignInFragmentTest$testStartTwitterSignIn$1.perform(SignInFragmentTest.kt:44)
at androidx.fragment.app.testing.FragmentScenario$4.perform(FragmentScenario.java:423)
at androidx.fragment.app.testing.FragmentScenario$4.perform(FragmentScenario.java:415)
at androidx.test.core.app.ActivityScenario.lambda$onActivity$2$ActivityScenario(ActivityScenario.java:551)
at androidx.test.core.app.ActivityScenario$$Lambda$4.run(Unknown Source)
at androidx.test.core.app.ActivityScenario.onActivity(ActivityScenario.java:561)
at androidx.fragment.app.testing.FragmentScenario.onFragment(FragmentScenario.java:414)
at jp.cldh.signin.ui.SignInFragmentTest.testStartTwitterSignIn(SignInFragmentTest.kt:79)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:546)
at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:252)
at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
I think the cause of this error is mismatch of return value from AccessibilityValidator.checkAndReturnResults
- actual
java.util.List
- expected by espresso
com.google.common.collect.ImmutableList
Steps to Reproduce
Run espresso test with AccessibilityChecks.enable().setRunChecksFromRootView(true)
.
Expected Results
Run test with no error.
Actual Results
java.lang.NoSuchMethodError
AndroidX Test and Android OS Versions
espresso version = 3.2.0-beta01 androidx test version = 1.2.0-beta01
Link to a public git repo demonstrating the problem:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 15 (2 by maintainers)
An update: We pinged the a11y team again last week. This issue is on a11y team’s radar and they are actively working on addressing it.
As a work-around until this is fixed:
copy this file into your project under
app/src/androidTest/java/androidx/test/espresso/accessibility/
remove this:
If I build
androidx-test-1.2.1-alpha02
locally, and use theespresso-accessibility
from my local build it works fine…Seems like the artifact on
maven.google.com
were built against a different version of this artifact:com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.0
From here: https://github.com/google/Accessibility-Test-Framework-for-Android/blame/master/src/main/java/com/google/android/apps/common/testing/accessibility/framework/integrations/espresso/AccessibilityValidator.java#L58
you can see
But looks like the distributed artifact was compiled using some other version of the
accessibility-test-framework
with this method signature:Does Google have some alternative version of
accessibility-test-framework
internally that was used to build the androidx.test artifacts?The new a11y library is not available yet. For now, please try to upgrade to espresso 3.3.0-alpha03
Apologies for the delay with this issue. There has been some unforeseen delays with the new a11y library release.
We just pushed a new AndroidX Test release, that contains a workaround. See https://github.com/android/android-test/releases/tag/androidx-test-1.3.0-alpha03
Please give it a try and reopen this issue if you continue to experience problems. Thanks!
@yogurtearl Michael, I think you are probably right. Figuring out how to fix the a11y dependencies.
Same issue here, using espresso = 3.2.0. It happens any time an accessibility check is run, root view or not.
I’m having same issue. Sample app to repoduce it here: https://github.com/jacobduron90/EspressoIssue