当前位置: 首页 > 知识库问答 >
问题:

对任务执行Android生成错误失败:“应用程序:checkDebugDuplicateClasses”

景英杰
2023-03-14

应用程序构建错误:'app:checkDebug重复类' 我知道通过删除一个类可以解决此错误,但我不知道如何删除它,或者有任何其他方法可以解决此问题。

谢啦

失败:生成失败,出现异常。问题:任务“:app:checkDebugDuplicateClasss”的执行失败。执行com.android.build.gradle.internal.tasks时出错。检查DuplicatesRunnable重复类com.google.firebase.iid。FirebaseInstanceIdReceiver位于模块jetified-frirebase-iid-21.0.1-runtime(com.google.firebase:firebase-iid:21.0.1)和模块jetified-firebase-messaging-22.0.0-runtime。com/r/tools/classpath同步错误修复依赖项解析错误

>

  • 尝试:使用 --堆栈跟踪选项运行以获取堆栈跟踪。使用 --info 或 --调试选项运行以获取更多日志输出。运行 --scan 以获取完整的见解。

    在https://help.gradle.org获得更多帮助

    BUILD 在 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
    }
    
  • 共有2个答案

    缑智敏
    2023-03-14

    在gradle.properties文件中启用androidX和Jetifier。将以下几行添加到gradle.properties文件中:

    android.useAndroidX=true 
    android.enableJetifier=true
    
    孔彭祖
    2023-03-14

    您将mavenCentral和jcenter都作为存储库。从项目渐变文件中删除jcenter(),因为它已经过时。

    此外,删除Firebase消息依赖项的版本:实现com.google.firebase:Firebase消息传递

     类似资料:
    • 我正在使用最新的android studio build 1.5,因为我想导入一个需要NDK的eclipse项目。我的项目正在进行中。我尝试导入组织。阿帕奇。工具。蚂蚁taskdefs。条件操作系统,但在我构建APK时,它正在工作,它会出错: 我的build.gradle: 我的local.properties: 请帮我修复错误。非常感谢你!

    • 我得到这些错误,当我运行我的代码。请任何想法,我怎么能修复这些?我升级了颤振,pubspeck.lock.我提到代码是旧的,我试图升级 > 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。运行--扫描以获得完整的见解。 获取更多帮助https://help.gradle.org

    • 当我要构建apk时,我收到此错误。 执行任务“app:transformClassesWithDexForDebug”失败。 这是错误的截图

    • 错误:任务“:app:checkdebugaarmadata”的执行失败 发生多个任务操作失败:执行com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction时发生失败

    • 每当我运行、制作或清理项目时, 出现此错误消息。 我已经检查了我的资源文件好几次,没有出现致命错误。只有png图标和xml文件。 我不知道“-1”是什么意思。。 在我的主java文件中,有“无法解析符号R”错误。 我的应用程序昨晚启动得很好,但当我今天早上醒来运行android studio时,它失败了。 我该怎么办? 这是我的猎物 在下面,我添加了我的全部gradle输出,谢谢。 执行任务:[:

    • 我正在使用这个库https://github.com/mikepenz/MaterialDrawer 当我尝试运行我的项目时,我得到以下错误: 错误: 错误:任务': app: dexDebug'的执行失败。com.android.ide.common.process.ProcessExc0019:org.gradle.process.internal.ExecExc0019: Process'命