Android Gradle error: w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:

Android Gradle error: w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:

我正在做一个 Android Kotlin 项目。我正在尝试在我的项目中安装 AppInspector 插件。 https://app.appspector.com/58276/setup-guide。我在 Gradle 文件中放入所需的依赖项并同步它们。没有错误。但是当我尝试 运行 模拟器上的应用程序时出现错误。

这是我的项目gradle文件。

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlinVersion = '1.3.61'
    ext.apolloReleaseVersion = '1.1.3'
    ext.daggerVersion = '2.25.3'
    ext.expressoVersion = '3.2.0'
    ext.lifecycleVersion = "2.0.0"

    repositories {
        google()
        jcenter()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url "https://jitpack.io" }
        maven { url "https://maven.appspector.com/artifactory/android-sdk" }
    }
    dependencies {
        classpath "com.appspector:android-sdk-plugin:1.+"
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "com.apollographql.apollo:apollo-gradle-plugin:$apolloReleaseVersion"
        classpath 'com.android.tools.build:gradle:3.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的应用 Gradle 文件。

apply plugin: 'com.android.application'

apply plugin: 'com.appspector.sdk'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'com.apollographql.android'

apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.memento"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
//        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunner "com.example.memento.MockTestRunner"
        testInstrumentationRunnerArguments clearPackageData: 'true'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    repositories {
        maven {
            url "https://maven.appspector.com/artifactory/android-sdk"
        }
    }
    testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR'

        unitTests {
            includeAndroidResources = true
        }
    }
}

kapt {
    generateStubs = true
}

apollo {
    customTypeMapping = [
         "DateTime": "org.joda.time.DateTime"
    ]
}

dependencies {
    def moshiVersion="1.8.0"
    def retrofit2Version = "2.5.0"
    def okhttp3Version = "3.12.0"
    def kotlinCoroutineVersion = "1.0.1"
    def picassoVersion = "2.71828"

    implementation fileTree(dir: 'libs',    include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation "com.appspector:android-sdk:1.+"
    implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
    implementation "com.apollographql.apollo:apollo-runtime:$apolloReleaseVersion"
    implementation "com.apollographql.apollo:apollo-android-support:$apolloReleaseVersion"
    implementation "com.apollographql.apollo:apollo-rx2-support:$apolloReleaseVersion"
    implementation "com.apollographql.apollo:apollo-http-cache:$apolloReleaseVersion"
    implementation "com.google.dagger:dagger:$daggerVersion"
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutineVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutineVersion"
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
    implementation "com.google.dagger:dagger-android:$daggerVersion"
    implementation "com.google.dagger:dagger-android-support:$daggerVersion"
    implementation 'joda-time:joda-time:2.9.4'
    implementation 'org.mockito:mockito-core:2.7.22'
    //Moshi
    implementation "com.squareup.moshi:moshi-kotlin:$moshiVersion"
    kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion"
    //Retrofit2
    implementation "com.squareup.retrofit2:retrofit:$retrofit2Version"
    implementation "com.squareup.retrofit2:converter-moshi:$retrofit2Version"
    implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2"
    //Okhttp3
    implementation "com.squareup.okhttp3:okhttp:$okhttp3Version"
    implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
    //Picasso for Image Loading
    implementation ("com.squareup.picasso:picasso:$picassoVersion"){
        exclude group: "com.android.support"
    }
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
    api 'com.otaliastudios:cameraview:2.5.0'
    kapt "com.google.dagger:dagger-compiler:$daggerVersion"
    kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
    kaptTest "com.google.dagger:dagger-compiler:$daggerVersion"
    androidTestUtil 'androidx.test:orchestrator:1.2.0'
    compileOnly "javax.annotation:jsr250-api:1.0"
    testImplementation 'junit:junit:4.12'
    testImplementation 'androidx.test:core:1.2.0'
    testImplementation 'org.mockito:mockito-core:2.7.22'
    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation "androidx.test.espresso:espresso-core:$expressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-intents:$expressoVersion"
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test:rules:1.2.0'
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
    androidTestImplementation 'com.android.support.test:runner:1.1.1'
    androidTestImplementation 'org.mockito:mockito-android:2.7.22'
    androidTestImplementation('com.android.support.test.espresso:espresso-contrib:3.0.2') {
        // Necessary to avoid version conflicts
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude module: 'recyclerview-v7'
    }
}

当我尝试 运行 应用程序时,出现以下错误。

w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:

我的代码有什么问题,我该如何解决?

我发现了问题。使用应用 Gradle 文件。以下片段

repositories {
        maven {
            url "https://maven.appspector.com/artifactory/android-sdk"
        }
    }

应该在依赖项部分之前。而且它不应该在以下块内。

android {
   //the rest of the code
}