英文:
how to Fix Class duplication errors in Android studio
问题
我正试图在 build.gradle 文件中添加 Firebase。然而,似乎没有生效。
这是我的 build.gradle 文件,下面是错误信息。
我甚至查看了一些之前的 Stack Overflow 问题,但它们都没有起作用,请帮我解决一下!
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'
}
错误信息
在模块 jetified-play-services-vision-20.0.0-runtime.jar(com.google.android.gms:play-services-vision:20.0.0)和 jetified-play-services-vision-common-19.1.0-runtime.jar(com.google.android.gms:play-services-vision-common:19.1.0)中发现重复类 com.google.android.gms.internal.vision.zze
在模块 jetified-play-services-vision-20.0.0-runtime.jar(com.google.android.gms:play-services-vision:20.0.0)和 jetified-play-services-vision-common-19.1.0-runtime.jar(com.google.android.gms:play-services-vision-common:19.1.0)中发现重复类 com.google.android.gms.internal.vision.zzf
在模块 jetified-play-services-vision-20.0.0-runtime.jar(com.google.android.gms:play-services-vision:20.0.0)和 jetified-play-services-vision-common-19.1.0-runtime.jar(com.google.android.gms:play-services-vision-common:19.1.0)中发现重复类 com.google.android.gms.internal.vision.zzg
在模块 jetified-play-services-vision-20.0.0-runtime.jar(com.google.android.gms:play-services-vision:20.0.0)和 jetified-play-services-vision-common-19.1.0-runtime.jar(com.google.android.gms:play-services-vision-common:19.1.0)中发现重复类 com.google.android.gms.internal.vision.zzh
在模块 jetified-play-services-vision-20.0.0-runtime.jar(com.google.android.gms:play-services-vision:20.0.0)和 jetified-play-services-vision-common-19.1.0-runtime.jar(com.google.android.gms:play-services-vision-common:19.1.0)中发现重复类 com.google.android.gms.internal.vision.zzi
在模块 jetified-play-services-vision-20.0.0-runtime.jar(com.google.android.gms:play-services-vision:20.0.0)和 jetified-play-services-vision-common-19.1.0-runtime.jar(com.google.android.gms:play-services-vision-common:19.1.0)中发现重复类 com.google.android.gms.internal.vision.zzv
在模块 jetified-play-services-vision-20.0.0-runtime.jar(com.google.android.gms:play-services-vision:20.0.0)和 jetified-play-services-vision-common-19.1.0-runtime.jar(com.google.android.gms:play-services-vision-common:19.1.0)中发现重复类 com.google.android.gms.internal.vision.zzw
请查阅文档以了解如何解决依赖冲突错误。
<details>
<summary>英文:</summary>
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.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.
答案1
得分: 5
目前解决方法似乎是将 firebase-ml-vision
降级至 24.0.3
版本。
英文:
For now the fix seems to be to downgrade firebase-ml-vision
to 24.0.3
答案2
得分: 0
从现在开始,ML Kit作为独立的SDK提供。为了避免出现这样的问题,请按照迁移指南迁移您的应用。
英文:
Going forward, ML Kit is offered as a Standalone SDK. To avoid issues like these, please migrate your app by following the migration guide.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论