Flutter Execution failed for task ':app:checkDebugDuplicateClasses'

1.8k views Asked by At

I was running my flutter and changed some dependencies and gradle. However, I get such error like this.

Below is my build.gradle and errors I have seen many posts but I do not see any related posts on this error. I have published my app into IOS but I am trying to convert my flutter app to ANDROID. It worked to build at first. However, It wont build now.

    buildscript {
    ext.kotlin_version = '1.4.32'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
    }
    allprojects {
    repositories {
        google()
        jcenter()
    }
    }

     rootProject.buildDir = '../build'
     subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}" 
     }
      subprojects {
    project.evaluationDependsOn(':app')
        }

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

Below is error

'''
     Launching lib/main.dart on sdk gphone x86 arm in debug mode...
     Running Gradle task 'assembleDebug'...

FAILURE: Build 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.google.android.gms.internal.measurement.zzbj found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzbk found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzbl found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzbm found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzbn found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzbo found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzbp found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzbq found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzbr found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzbs found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzi found in modules jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzis found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzit found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zziu found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zziv found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zziw found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzix found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zziy found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zziz found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzj found in modules jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2) and jetified-play-services-measurement-sdk-api-18.0.3-runtime (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
     Duplicate class com.google.android.gms.internal.measurement.zzja found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjb found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjc found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjd found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzje found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjf found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjg found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjh found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzji found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjj found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjk found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjl found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjm found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjn found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjo found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjp found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjq found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjr found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjs found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjt found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzju found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjv found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjw found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjx found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjy found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzjz found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzka found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkb found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkc found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkd found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzke found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkf found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkg found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkh found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzki found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkj found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkk found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkl found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.internal.measurement.zzkm found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.measurement.internal.zzfh found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3)
     Duplicate class com.google.android.gms.measurement.internal.zzgl found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3)
     Duplicate class com.google.android.gms.measurement.internal.zzgm found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3)
     Duplicate class com.google.android.gms.measurement.internal.zzgn found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3)
     Duplicate class com.google.android.gms.measurement.internal.zzgo found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3)
     Duplicate class com.google.android.gms.measurement.internal.zzgp found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3)
     Duplicate class com.google.android.gms.measurement.internal.zzgq found in modules jetified-play-services-measurement-17.2.2-runtime (com.google.android.gms:play-services-measurement:17.2.2) and jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3)
     Duplicate class com.google.android.gms.measurement.internal.zzhs found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
     Duplicate class com.google.android.gms.measurement.internal.zzhx found in modules jetified-play-services-measurement-base-18.0.3-runtime (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-17.2.2-runtime (com.google.android.gms:play-services-measurement-impl:17.2.2)
Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
Exception: Gradle task assembleDebug failed with exit code 1
'''
2

There are 2 answers

0
Karan Mehta On

Make your project/build.gradle file structure like this :

buildscript {
    ext.kotlin_version = "1.4.32"
    ext.hilt_version = '2.40'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}
0
Jeevan Shrestha On

chnage the kotlin version in your gradle file.Then it will work.