Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate class com.google.android.gms.internal.vision.zze found in modules

I am trying to build an app with openCV and Firebase ML Kit. But I get the following error while building project:

Duplicate class com.google.android.gms.internal.vision.zze 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.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.

I have tried searching exact same error and didn't get anything, then I searched duplicate class issues, there wasn't a certain way of solving the problem, everyone shared their experience and neither of them worked for me.

This is my build.gradle file:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.cameraactivity"
        minSdkVersion 21
        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'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'

    implementation 'com.google.firebase:firebase-ml-vision:24.1.0'
    implementation project(path: ':sdk')

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}

It's all about this line:

implementation 'com.google.firebase:firebase-ml-vision:24.1.0'

When I comment this line, it doesn't give errors when I build project (I haven't added functionality yet). Thanks in advance

like image 330
Tugay Avatar asked Sep 10 '20 13:09

Tugay


2 Answers

Add the following in build.gradle:Module

implementation 'com.google.android.gms:play-services-vision:20.0.0'

implementation 'com.google.firebase:firebase-ml-vision:24.0.3'
implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.1.1'

And in build.gradle:Project

classpath 'com.google.gms:google-services:4.3.3'

In buildscript-->dependencies.

like image 173
l_b Avatar answered Oct 16 '22 12:10

l_b


I had the same issue with the 24.1.0 version of firebase-ml-vision. Here is the official resolution solution :

Firebase Release Note MLKIT Self Serve Fixes

So I had to add a dependency to play-services-vision that I did not need anymore before :

implementation 'com.google.android.gms:play-services-vision:20.1.1'

I hope that they will fix it in the next versions

like image 6
Rémi P Avatar answered Oct 16 '22 13:10

Rémi P