首页 > 解决方案 > 如何修复重复类 org.jetbrains.annotations.TestOnly 错误?

问题描述

我收到很多这样的错误:Duplicate class org.jetbrains.annotations.TestOnly found in the following modules:...

这表明我错过了一个排除项,但我的 build.gtadle 中有以下几行

configurations {
    cleanedAnnotations
    compile.exclude group: 'org.jetbrains' , module:'annotations'
    compile.exclude group: 'org.jetbrains.kotlin' , module:'kotlin-stdlib'
    compile.exclude group: 'com.intellij', module:'annotations'
}

那么缺少什么?

编辑:

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    
    //Firebase
    implementation ("com.google.firebase:firebase-core:17.2.0") {
        exclude group: "com.android.support", module: "support-v4"
    }
    implementation 'com.google.firebase:firebase-messaging:20.0.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.1'
    implementation 'com.google.firebase:firebase-plugins:2.0.0'
    implementation 'com.google.firebase:firebase-crash:16.2.1'
    implementation 'com.google.firebase:firebase-ml-vision:24.0.0'
    implementation ("com.google.firebase:firebase-auth:19.1.0") {
        exclude group: "com.android.support", module: "support-v4"
    }
    implementation 'com.google.firebase:firebase-database:19.1.0'
    implementation 'com.google.firebase:firebase-storage:19.1.0'
    //Graphview
    implementation 'com.jjoe64:graphview:4.2.1'
    implementation 'org.apache.commons:commons-lang3:3.4'
    //Google Play
    implementation ("com.google.android.gms:play-services-base:17.1.0") {
        exclude group: "com.android.support", module: "support-v4"
    }
    implementation "com.google.android.gms:play-services-auth:17.0.0"
    implementation "com.google.android.gms:play-services-identity:17.0.0"
    //FirebaseUI
    implementation 'com.firebaseui:firebase-ui-auth:6.0.2'
    implementation 'com.firebaseui:firebase-ui-storage:6.0.2'
    implementation 'com.facebook.android:facebook-android-sdk:5.8.0'
    implementation 'com.twitter.sdk.android:twitter-core:3.1.1'
    //Support
    implementation "androidx.appcompat:appcompat:1.1.0"
    implementation "androidx.appcompat:appcompat-resources:1.1.0"
    implementation "androidx.navigation:navigation-fragment-ktx:2.2.1"
    implementation "androidx.drawerlayout:drawerlayout:1.0.0"
    implementation "androidx.gridlayout:gridlayout:1.0.0"
    implementation "androidx.preference:preference:1.1.0"
    implementation "androidx.recyclerview:recyclerview:1.1.0"
    implementation "androidx.cardview:cardview:1.0.0"

    implementation "io.reactivex.rxjava2:rxjava:2.2.13"
    implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
    //Glide
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

    /**
     * dependency to request the runtime permissions.
     */
    implementation 'com.karumi:dexter:4.2.0'

    // code generator for view
    implementation "com.jakewharton:butterknife:10.2.0"
    annotationProcessor "com.jakewharton:butterknife-compiler:10.2.0"
    testImplementation 'junit:junit:4.12'
}

所以这是我的依赖项,我没有直接包含这些包,但不知何故,我间接猜测它们。

这似乎是帖子的太多代码,所以我必须添加一些文本

标签: androidandroid-studio

解决方案


从您的依赖项中删除implementation 'com.jjoe64:graphview:4.2.1'已知会导致重复的类错误。

您还可以使用实现'com.jjoe64:graphview:4.2.2'


推荐阅读