Java “多重”;“重复类”;Android Studio中的错误

Java “多重”;“重复类”;Android Studio中的错误,java,android,android-studio,Java,Android,Android Studio,因此,我尝试运行我的Android应用程序,但出现以下错误: Duplicate class org.jetbrains.annotations.Contract found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddab

因此,我尝试运行我的Android应用程序,但出现以下错误:

Duplicate class org.jetbrains.annotations.Contract found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.Nls found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.NonNls found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.NotNull found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.Nullable found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.PropertyKey found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.TestOnly found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)

Go to the documentation to learn how to Fix dependency resolution errors.

我真的不能对这些错误掉以轻心,因为我甚至没有在我的整个应用程序中以任何方式使用Kotlin。它被配置为Java应用程序

My build.gradle(模块:应用程序)如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude "**/kotlin/**"
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.journeyapps:zxing-android-embedded:2.0.1@aar'
    implementation 'com.journeyapps:zxing-android-integration:2.0.1@aar'
    implementation 'com.google.zxing:core:3.2.1'
    implementation 'me.dm7.barcodescanner:zxing:1.9'
    // https://mvnrepository.com/artifact/org.web3j/parity
    implementation 'org.web3j:core:4.5.7'
    implementation 'org.web3j:parity:4.5.5'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'

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

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

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
另一个build.gradle(项目:App)如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude "**/kotlin/**"
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.journeyapps:zxing-android-embedded:2.0.1@aar'
    implementation 'com.journeyapps:zxing-android-integration:2.0.1@aar'
    implementation 'com.google.zxing:core:3.2.1'
    implementation 'me.dm7.barcodescanner:zxing:1.9'
    // https://mvnrepository.com/artifact/org.web3j/parity
    implementation 'org.web3j:core:4.5.7'
    implementation 'org.web3j:parity:4.5.5'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'

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

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

    }
}

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

在我阅读了有类似重复类错误的人关于StackOverflow的其他问题/答案后,我将
mavenCentral()
jcenter()
添加到存储库中。

尝试使用排除组:“com.google.common”,模块:“注释”谢谢大家,但这仍然不能解决我的问题。请尝试使用排除组:“com.google.common”,模块:“注释”谢谢大家,但这仍然不能解决我的问题。