gpt4 book ai didi

android - 由于 IncompatibleClassChangeError,Espresso 测试失败

转载 作者:行者123 更新时间:2023-12-05 00:17:47 26 4
gpt4 key购买 nike

Espresso 测试运行良好,但在尝试检查是否出现 toast 消息时,使用此代码

onView(withText(R.string.added_successfully_msg)).inRoot(toastMatcher())
.check(matches(withText(R.string.added_successfully_msg)));
或者这个
onView(withText(R.string.added_successfully_msg)).inRoot(withDecorView(not(activity.getWindow().getDecorView()))).check(matches(isDisplayed()));
抛出此异常
java.lang.IncompatibleClassChangeError: Class 'org.hamcrest.StringDescription' does not implement interface 'java.lang.Iterable' in call to 'java.util.Iterator java.lang.Iterable.iterator()' (declaration of 'org.hamcrest.BaseDescription' appears in /data/app/my package name.test-7NCoDq2dIYza4GpnMXXGhQ==/base.apk)
at org.hamcrest.BaseDescription.appendValueList(BaseDescription.java:81)
at androidx.test.espresso.matcher.BoundedDiagnosingMatcher.describeTo(BoundedDiagnosingMatcher.java:4)
at org.hamcrest.BaseDescription.appendDescriptionOf(BaseDescription.java:24)
at org.hamcrest.StringDescription.toString(StringDescription.java:28)
at org.hamcrest.BaseMatcher.toString(BaseMatcher.java:26)
at java.util.Formatter$FormatSpecifier.printString(Formatter.java:2978)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2855)
at java.util.Formatter.format(Formatter.java:2524)
at java.util.Formatter.format(Formatter.java:2459)
at java.lang.String.format(String.java:2911)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:12)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
测试依赖
  testImplementation 'androidx.test:monitor:1.5.0'
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-core:3.12.4"
// Core library
androidTestImplementation 'androidx.test:core:1.4.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.1-alpha06'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'

// Espresso dependencies
def espressoVersion = "3.5.0-alpha06"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation ("androidx.test.espresso:espresso-contrib:$espressoVersion"){exclude module: 'protobuf-lite'}
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
我认为当我使用 withText() 时会引发此异常但我找不到解决方案。
感谢帮助

最佳答案

我也刚遇到这个。我认为这可能是 espresso 3.5.0-alpha06 中的一个错误 - 如果我恢复到 3.5.0-alpha04 它会再次起作用
我还没有找到向谷歌提交的错误,但它可能值得做。
这可能是与另一个不兼容的库发生冲突,但我还无法确定确切的原因。
更新 :
似乎在上次更新 3.5.0-alpha07 中解决了

关于android - 由于 IncompatibleClassChangeError,Espresso 测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72351022/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com