首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >重复的类错误:任务':app:checkDebugDuplicateClasses‘执行失败

重复的类错误:任务':app:checkDebugDuplicateClasses‘执行失败
EN

Stack Overflow用户
提问于 2021-08-04 19:03:25
回答 2查看 451关注 0票数 2

我一直在尝试运行我的应用程序,但它得到了一个错误:

代码语言:javascript
运行
复制
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class org.intellij.lang.annotations.Flow found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.Identifier found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$AdjustableOrientation found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$BoxLayoutAxis found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$CalendarMonth found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$CursorType found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$FlowLayoutAlignment found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$FontStyle found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$HorizontalAlignment found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$InputEventMask found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$ListSelectionMode found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$PatternFlags found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$TabLayoutPolicy found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$TabPlacement found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$TitledBorderJustification found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$TitledBorderTitlePosition found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.JdkConstants$TreeSelectionMode found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.Language found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.MagicConstant found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.Pattern found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.PrintFormat found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.PrintFormatPattern found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.RegExp found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.intellij.lang.annotations.Subst found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.jetbrains.annotations.Contract found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.jetbrains.annotations.Nls found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.jetbrains.annotations.NonNls found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.jetbrains.annotations.NotNull found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.jetbrains.annotations.Nullable found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.jetbrains.annotations.PropertyKey found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)
     Duplicate class org.jetbrains.annotations.TestOnly found in modules jetified-annotations-13.0 (org.jetbrains:annotations:13.0) and jetified-annotations-java5-21.0.1 (org.jetbrains:annotations-java5:21.0.1)

这是我的build.gradle(模块):

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.avs.app"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
    implementation 'com.mikhaellopez:circularimageview:4.3.0'
    implementation 'com.loopj.android:android-async-http:1.4.11'
    implementation 'cz.msebera.android:httpclient:4.5.8'
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'org.jetbrains:annotations-java5:21.0.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

看一下构建错误,我猜它与"implementation 'org.jetbrains:annotations-java5:21.0.1'“有关。

Build.gradle(应用程序):

代码语言:javascript
运行
复制
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}

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

Gradle-wrapper.properties:

代码语言:javascript
运行
复制
#Thu Mar 12 17:34:37 PST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

Gradle.properties:

代码语言:javascript
运行
复制
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

那么,我应该从build.gradle中删除"jetbrains-annotations“行吗?我认为删除它会导致错误。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-08-04 19:05:55

正如我所想的,解决方案是从build.gradle中删除一行:

代码语言:javascript
运行
复制
implementation 'org.jetbrains:annotations-java5:21.0.1'
票数 1
EN

Stack Overflow用户

发布于 2021-10-21 13:41:21

最近有过这样的经历。

注意到你有

代码语言:javascript
运行
复制
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

这就是这个问题的原因。

有关解决方案/解决方法,请参阅此特定注释:

https://github.com/android/android-test/issues/861#issuecomment-872582819

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68656768

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档