首页 > 解决方案 > 将 aws-java-sdk:1.11.973 添加到我的 gradle 文件并运行不断抛出在模块错误中发现的重复类

问题描述

我已经阅读了很多类似的问题和解决方案,但似乎没有解决问题。这是我的 build.gradle 文件

    plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30

    defaultConfig {
        applicationId "com.****"
        minSdkVersion 26
        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
        // Support for Java 8 features
        coreLibraryDesugaringEnabled true
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

dependencies {

    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.hbb20:ccp:2.2.2'
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
    implementation 'com.github.bumptech.glide:glide:4.12.0'

    implementation 'com.amplifyframework:aws-auth-cognito:1.18.0'

    implementation 'com.amazonaws:aws-java-sdk:1.11.973'

    // Support for Java 8 features
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

    implementation 'com.amplifyframework:aws-datastore:1.18.0'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

这是我得到的错误

    FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.amazonaws.AbortedException found in modules jetified-aws-android-sdk-core-2.25.0-runtime (com.amazonaws:aws-android-sdk-core:2.25.0) and jetified-aws-java-sdk-core-1.11.404 (com.amazonaws:aws-java-sdk-core:1.11.404)
     Duplicate class com.amazonaws.AmazonClientException found in modules jetified-aws-android-sdk-core-2.25.0-runtime (com.amazonaws:aws-android-sdk-core:2.25.0) and jetified-aws-java-sdk-core-1.11.404 (com.amazonaws:aws-java-sdk-core:1.11.404)
     Duplicate class com.amazonaws.AmazonServiceException found in modules jetified-aws-android-sdk-core-2.25.0-runtime (com.amazonaws:aws-android-sdk-core:2.25.0) and jetified-aws-java-sdk-core-1.11.404 (com.amazonaws:aws-java-sdk-core:1.11.404)
     Duplicate class com.amazonaws.AmazonServiceException$ErrorType found in modules jetified-aws-android-sdk-core-2.25.0-runtime (com.amazonaws:aws-android-sdk-core:2.25.0) and jetified-aws-java-sdk-core-1.11.404 (com.amazonaws:aws-java-sdk-core:1.11.404)

还有更多重复。以前我使用独立依赖项来满足我的需要,但后来我必须获得导致此错误的完整 sdk。请帮忙。

标签: javaandroidamazon-web-servicesaws-java-sdk

解决方案


推荐阅读