Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Espresso test error: No static method loadSingleServiceOrNull()

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.

like image 991
Captain Jacky Avatar asked May 02 '21 15:05

Captain Jacky


Video Answer


1 Answers

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.

like image 55
kimv Avatar answered Sep 24 '22 10:09

kimv