Ошибка сборки Android. Не удалось выполнить задачу ': app: checkDebugDuplicateClasses'

Ошибка создания приложения: 'app: checkDebugDuplicateClasses'. Я знаю, что удаление одного класса может решить эту ошибку, но я не знаю, как удалить его или есть какой-либо другой способ решить эту проблему.

Благодарность

ОШИБКА: сбой при сборке за исключением. Что пошло не так: не удалось выполнить задачу ': app: checkDebugDuplicateClasses'. Ошибка при выполнении com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable Дубликат класса com.google.firebase.iid.FirebaseInstanceIdReceiver, обнаруженный в модулях jetified-firebase-iid-21.0.1-runtime (com.google.firebase: firebase-iid: 21.0.1) и jetified-firebase-messaging-22.0.0-runtime (com.google.firebase: firebase-messaging: 22.0.0) Перейдите в документацию, чтобы узнать, как d.android.com/r / tools / classpath-sync-errors Исправить ошибки разрешения зависимостей

  • Попробуйте: запустить с параметром --stacktrace, чтобы получить трассировку стека. Запустите с параметром --info или --debug, чтобы получить дополнительный вывод журнала. Запустите с --scan, чтобы получить полную информацию.

  • Получите дополнительную помощь на странице https://help.gradle.org

СТРОИТЬ НЕ УДАЛАСЬ за 1 мин. 28 с. 18 задач, требующих выполнения: 18 выполненных.

Это мой файл градиента модуля

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'

}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.shipelse"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        multiDexEnabled true


        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
            minifyEnabled true
            //useProguard true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.navigation:navigation-fragment:2.3.5'
    implementation 'androidx.navigation:navigation-ui:2.3.5'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
    implementation 'com.google.firebase:firebase-auth:21.0.1'
    implementation 'com.google.firebase:firebase-messaging:22.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.preference:preference:1.1.1'

    implementation 'androidx.core:core:1.5.0'
    implementation 'androidx.drawerlayout:drawerlayout:1.1.1'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation platform('com.google.firebase:firebase-bom:26.2.0')
    implementation 'com.google.firebase:firebase-analytics'

    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.android.gms:play-services-location:18.0.0'

    //noinspection GradleCompatible
    implementation 'androidx.core:core:1.5.0'

    implementation "androidx.security:security-crypto:1.0.0"

    // For Identity Credential APIs
    implementation "androidx.security:security-identity-credential:1.0.0-alpha02"
}

Это мой файл градиента проекта

buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()
        gradlePluginPortal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
        classpath 'com.google.gms:google-services:4.3.8'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url "https://jitpack.io" }
        maven {
            url 'https://maven.mapmyindia.com/repository/mapmyindia/'
        }
    }
}

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

person Mohanasundar    schedule 22.05.2021    source источник
comment
Кажется, у вас есть сочетание зависимостей Firebase, некоторые из которых полагаются на спецификацию для версий, другие с версиями, указанными непосредственно в закрытии dependencies. Это кажется непоследовательным и может усугублять вашу проблему. Вы пробовали удалить номера версий из com.google.firebase:firebase-auth и com.google.firebase:firebase-messaging, чтобы больше походить на то, как у вас com.google.firebase:firebase-analytics и com.google.firebase:firebase-auth?   -  person CommonsWare    schedule 22.05.2021


Ответы (1)


У вас есть как репозитории mavenCentral, так и jcenter. Удалите jcenter () из файла gradle вашего проекта, поскольку он уже устарел.

Также удалите версию вашей зависимости firebase-messaging: implementation 'com.google.firebase: firebase-messaging'

person Roney Sampaio    schedule 07.06.2021