当我在一周前进行测试时,每个测试都很好,但现在我发现了这个错误:

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())

What could be the cause? Thank you.

推荐答案

Issue occurred 到 me when I updated

androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

Reverting 到 version 3.3.0 fixed things.

Kotlin相关问答推荐

如何在Kotlin中模拟www.example.com()?

Jetpack Compose Material3和Material2 Slider onValueChangeFinded()的行为不同

为什么";";.equals(1)在柯特林语中是有效的,但";";=1是无效的?

在Kotlin 有更好的结合方式?

如何进行基于lambda/谓词的两个列表的交集?

在构造函数中创建内部类实例时,只能使用包含类的接收器调用内部类的构造函数

kotlin - 挂起简单方法调用链时可能存在冗余分支

Kotlin - 什么时候和什么时候不喜欢内联函数,为什么?

用于将 0.5 变为 0 的 round() 函数的模拟

Jetpack Compose 中的连续重组

Kotlin:泛型、反射以及类型 T 和 T:Any 之间的区别

防止导航到同一个片段

在kotlin中,如何模拟封装回调函数?

使用 Kotlin 创建自定义 Dagger 2 范围

Kotlin Android:属性委托必须有一个 'getValue(DashViewModel, KProperty*>)' 方法

将 Double 转换为 ByteArray 或 Array Kotlin

如何使用mockk库模拟android上下文

在 Kotlin 中返回函数有不那么丑陋的方法吗?

在 Kotlin 中编写一个等于 Int.MIN_VALUE 的十六进制整数文字

Kotlin:测试中的 java.lang.NoSuchMethodError