0

我对 android studio 完全陌生。我正在尝试使用 Firebase-ML 阅读一些文本,但是当我尝试运行程序时出现重复的类错误

错误:

Duplicate class com.google.android.gms.internal.vision.zzu found in modules jetified-play-services-vision-common-19.1.3-runtime (com.google.android.gms:play-services-vision-common:19.1.3) and jetified-play-services-vision-image-labeling-internal-16.0.0-runtime (com.google.android.gms:play-services-vision-image-labeling-internal:16.0.0)

这是我的 Gradle 依赖项。

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation platform('com.google.firebase:firebase-bom:26.3.0')

    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'

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

    implementation 'com.google.firebase:firebase-ml-vision:24.1.0'
    implementation 'com.google.firebase:firebase-ml-vision-image-label-model:20.0.2'
    implementation 'com.google.android.material:material:1.2.1'

}

我不知道在这里做什么?

4

1 回答 1

0

我认为这可能与我在添加另一个 Google API 时遇到的相同。尝试将以下内容添加到您的 build.gradle:

    android {
    .
    .
    .
        // Firebase uses a smaller proto but other Google APIs uses the full system so I need to exclude the
        //  light libraries when using Google APIs with Firebase and then Firebase will use the
        //  full library
        configurations {
            implementation.exclude module: 'protobuf-lite'
        }
于 2021-01-21T23:53:18.770 回答