'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
Solution 1:[1]
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.
Solution 2:[2]
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
Solution 3:[3]
Alternatively and preferably, you should move to the new ML Kit SDK which we launched early June. The on-device APIs are considered deprecated in Firebase ML and updates / improvements are only available in the new SDK. To help with the switch, migration guides can be found here.
Solution 4:[4]
I have same issue,if you are using firebase dependencies update following to latest version in app/build.gradle see attached process
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.0.0')
}
Get the latest version via the documentation https://firebase.google.com/support/release-notes/android
Solution 5:[5]
We were facing a similar issue. I am going to add some steps here based on which hopefully someone else who faces this issue can later sort it out themselves. Our issue was,
Execution failed for task ':app:checkStagingReleaseDuplicateClasses'.
> 1 exception was raised by workers: java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.vision.zzbl found in modules play-services-vision-common-19.1.3-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.3) and play-services-vision-face-contour-internal-16.0.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.0.0)
We tried a lot of things, including steps mentioned here in these set of answers, but nothing worked. After a lot of brute forcing, and mind bending decryption of errors, we did this.
The error was simple, something was showing up in 2 places. Both places were not implemented anywhere in our build.gradle
. So it was obviously coming from the group in which the module is placed, in our case com.google.android.gms
. So, first we checked what's the version we have implemented for gms, only to realise nothing wrong there. Though we did play around a bit by upgrading and downgrading it, nothing really happened.
So we thought, why not just check where else in the app are one of the duplicates being implemented, only to realise, we have installed react-native-camera, which uses play-services-vision and has it implemented in it's own build.gradle
. So now, a bulb went off in our head, we have implemented react-native-camera in our own build.gradle too. Like so
implementation project(':react-native-camera')
. Why not make it stop trying to implement play-services-vision-face-contour-internal from our end?
Thus coming to the solution like so,
implementation (project(':react-native-camera')) {
exclude module: 'play-services-vision-face-contour-internal'
}
By doing this, the duplicate error stopped showing and we could continue with our development in peace.
I know there's not a lot of technical knowledge here, this is here just so someone could also look into something like this when they face something like this. I don't know if that made sense
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | l_b |
Solution 2 | RĂ©mi P |
Solution 3 | Chrisito |
Solution 4 | Thusitha Deepal |
Solution 5 | Ws7one |