Shubham K.
Shubham K.

Reputation: 105

how to Fix Class duplication errors in Android studio

I am trying to add Firebase in the build.gradle file. However, it doesn't seem to be working. this is my build.gradle file and below is the error. I even looked some previous stack-overflow question but they didn't work so please help me out.!

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
googleServices.disableVersionCheck = true
android {
    compileSdkVersion 29
    buildToolsVersion "30.0.1"

    defaultConfig {
        applicationId "com.teachbrowniesindia.textrecognizer"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-ml-vision:24.1.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    implementation 'com.google.android.gms:play-services-ads:19.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}


Error

Duplicate class com.google.android.gms.internal.vision.zzf found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzg found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzh found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzi found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzv found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzw found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)

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

Upvotes: 0

Views: 2131

Answers (2)

Chrisito
Chrisito

Reputation: 524

Going forward, ML Kit is offered as a Standalone SDK. To avoid issues like these, please migrate your app by following the migration guide.

Upvotes: 0

Simon
Simon

Reputation: 1737

For now the fix seems to be to downgrade firebase-ml-vision to 24.0.3

Upvotes: 5

Related Questions