6

kotlin collections library (listOf, first, toList, etc,..在我们的包中使用 ) 方法AndroidTest来运行 UI 测试AndroidJunit4 runner,无论我在哪里引用 kotlin 集合库,我都会遇到这些类型的错误。

java.lang.NoSuchMethodError: No static method listOf(Ljava/lang/Object;)Ljava/util/List; in class Lk/v/i; or its super classes (declaration of 'k.v.i' appears 

奇怪的是我在编译时没有看到任何问题,也没有在课堂级别独立运行测试时看到任何问题。仅当我使用 Gradle 运行整个测试套件时才会出现此问题

这是我使用 Gradle 运行 UI 测试套件的命令

./gradlew connectedCheck --info --full-stacktrace --no-build-cache --debug

我怀疑在运行时加载的类似乎与编译时不同

这是build.gradle依赖项


    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.71"

    //  Instrumented Tests
    testImplementation "androidx.test:core:1.2.0"
    androidTestImplementation 'androidx.test.ext:junit:1.1.1' 
    androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' 
    

  defaultConfig {
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  }

4

0 回答 0