Android Espresso test error: No static method loadSingleServiceOrNull()
Android Espresso test error: No static method loadSingleServiceOrNull()
1 周前我 运行 的测试一切正常,但现在我收到此错误:
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)
这一行抛出错误:
onView(withId(R.id.sign_in_button)).perform(click())
可能是什么原因?谢谢。
你有多个ServiceLoaderWrapper
,真正有API方法的是其中的一些,这个文件是androidx.test:monitor
带来的,我通过强制版本修复了它应用 gradle 文件中的包如下。
android {
...
configurations.all {
resolutionStrategy {
force 'androidx.test:monitor:1.4.0'
}
}
...
}
我更新时遇到问题
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
至
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
恢复到版本 3.3.0 修复了一些问题。
1 周前我 运行 的测试一切正常,但现在我收到此错误:
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)
这一行抛出错误:
onView(withId(R.id.sign_in_button)).perform(click())
可能是什么原因?谢谢。
你有多个ServiceLoaderWrapper
,真正有API方法的是其中的一些,这个文件是androidx.test:monitor
带来的,我通过强制版本修复了它应用 gradle 文件中的包如下。
android {
...
configurations.all {
resolutionStrategy {
force 'androidx.test:monitor:1.4.0'
}
}
...
}
我更新时遇到问题
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
至
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
恢复到版本 3.3.0 修复了一些问题。