Reputation: 1059
When I ran my tests 1 week ago every was fine, but now I get this error:
java.lang.NoSuchMethodError: No static method loadSingleServiceOrNull(Ljava/lang/Class;)Ljava/lang/Object; in class Landroidx/test/internal/platform/ServiceLoaderWrapper; or its super classes (declaration of 'androidx.test.internal.platform.ServiceLoaderWrapper' appears in /data/app/com.domain.myapp-1/base.apk)
at androidx.test.espresso.base.UiControllerModule.provideUiController(UiControllerModule.java:2)
at androidx.test.espresso.base.UiControllerModule_ProvideUiControllerFactory.provideUiController(UiControllerModule_ProvideUiControllerFactory.java:1)
at androidx.test.espresso.base.UiControllerModule_ProvideUiControllerFactory.get(UiControllerModule_ProvideUiControllerFactory.java:1)
at androidx.test.espresso.base.UiControllerModule_ProvideUiControllerFactory.get(UiControllerModule_ProvideUiControllerFactory.java:2)
at androidx.test.espresso.core.internal.deps.dagger.internal.DoubleCheck.get(DoubleCheck.java:6)
at androidx.test.espresso.DaggerBaseLayerComponent$ViewInteractionComponentImpl.viewInteraction(DaggerBaseLayerComponent.java:1)
at androidx.test.espresso.Espresso.onView(Espresso.java:1)
This line throws error:
onView(withId(R.id.sign_in_button)).perform(click())
What could be the cause? Thank you.
Upvotes: 18
Views: 4455
Reputation: 159
upgrading to 3.5.1 and removing the espresso-contrib dependency solved it for me
Upvotes: 2
Reputation: 309
You have multiple ServiceLoaderWrapper
, the one that actually has the API method is some of them, This file is brought by androidx.test:monitor
, I fixed it by forcing the version of the package in the app gradle file as following.
android {
...
configurations.all {
resolutionStrategy {
force 'androidx.test:monitor:1.4.0'
}
}
...
}
Upvotes: 19
Reputation: 1579
Issue occurred to me when I updated
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
to
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Reverting to version 3.3.0 fixed things.
Upvotes: 38