android - Firebase Android : Duplicate Protobuf classes found in modules

标签 android firebase gradle

因此,我在 2 周多来一直在努力解决这个影响我的 Android 应用程序的构建错误。
在模块 jetified-protobuf-javalite-3.11.0.jar (com.google.protobuf:protobuf-javalite:3.11.0) 和 jetified-protobuf-lite-3.0.1.jar 中发现重复的类 com.google.protobuf.AbstractMessageLite (com.google.protobuf:protobuf-lite:3.0.1)
我随机得到了这个错误,不知道该怎么办了。我浏览了整个互联网,并尝试了几乎所有我能想到的东西。我已将其范围缩小到 Firebase Firestore 是主要问题。我从 JAR 文件中手动删除类的尝试失败了。我只是把它扔在这里,看看是否有其他人经历过。
这是我的 build.gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
apply plugin: 'project-report'


android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 23
        targetSdkVersion 28
        multiDexEnabled true
        compileOptions {
            sourceCompatibility 1.8
            targetCompatibility 1.8
        }

        //Optionally configure your OneSignal IDs below
        manifestPlaceholders = [manifestApplicationId          : "${applicationId}",
                                onesignal_app_id               : "",
                                onesignal_google_project_number: ""]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }

        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.txt'
        }
    }
    dexOptions {
        jumboMode true
        javaMaxHeapSize "4g"
    }
}

repositories {
    flatDir {
        dirs 'libs'
    }
    maven {
        url "https://jitpack.io"
    }
    jcenter()
}

configurations {
    //Exclusions that I've tried
    //implementation.exclude module:'protolite-well-known-types'
    //implementation.exclude module:'guava'
    //implementation.exclude module:'protobuf-javalite'
    //implementation.exclude module:'proto-google-common-protos'
}

dependencies {
    implementation 'com.devbrackets.android:exomedia:4.3.0' //TV
    implementation 'com.google.android.exoplayer:exoplayer:2.9.6' //TV & Radio
    implementation 'com.cleveroad:audiovisualization:1.0.1' //Radio
    implementation 'com.google.code.gson:gson:2.8.5' //WC
    implementation 'com.squareup.okhttp3:okhttp:3.12.1'
    implementation 'org.jsoup:jsoup:1.8.3'
    implementation 'com.onesignal:OneSignal:3.12.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.duolingo.open:rtl-viewpager:1.0.2'
    implementation 'com.github.chrisbanes:PhotoView:1.3.0'
    implementation 'androidx.multidex:multidex:2.0.1'

    implementation 'androidx.multidex:multidex-instrumentation:2.0.0'
    implementation 'androidx.exifinterface:exifinterface:1.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.google.android.material:material:1.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
    implementation 'androidx.media:media:1.1.0'

    implementation "com.google.android.gms:play-services-oss-licenses:17.0.0"
    implementation "com.google.android.gms:play-services-gcm:17.0.0"
    implementation "com.google.android.gms:play-services-ads:19.3.0"
    implementation "com.google.android.gms:play-services-maps:17.0.0"
    //noinspection GradleDynamicVersion
    implementation 'com.google.maps.android:android-maps-utils:0.5+'
    implementation 'com.google.android.gms:play-services-auth:18.1.0'

    implementation 'com.google.firebase:firebase-analytics:17.4.4'
    implementation 'com.google.firebase:firebase-auth:19.3.2'
    implementation ('com.google.firebase:firebase-firestore:21.5.0')
    implementation 'com.google.firebase:firebase-database:19.3.1'
    implementation 'com.google.firebase:firebase-storage:19.1.1'
    implementation 'com.google.firebase:firebase-functions:19.0.2'
    implementation 'com.google.firebase:firebase-messaging:20.2.4'

    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    implementation 'com.android.billingclient:billing:2.0.3'


    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'de.hdodenhof:circleimageview:3.0.1'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'ja.burhanrashid52:photoeditor:1.0.0'

}
我的依赖树的结果显示 Protobuf 仅存在于 Firebase-Firestore 库中:
+--- com.google.firebase:firebase-firestore:21.5.0 -> 17.1.5
|    +--- com.google.android.gms:play-services-base:16.0.1 -> 16.1.0 (*)
|    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.2.0 (*)
|    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    +--- com.google.firebase:firebase-auth-interop:16.0.1 -> 17.0.0 (*)
|    +--- com.google.firebase:firebase-common:16.0.4 -> 17.1.0 (*)
|    +--- com.google.firebase:firebase-database-collection:16.0.1 -> 17.0.1
|    |    \--- com.google.android.gms:play-services-base:17.0.0 -> 16.1.0 (*)
|    +--- com.google.firebase:protolite-well-known-types:16.0.1 -> 17.1.0
|    |    \--- com.google.protobuf:protobuf-javalite:3.11.0
|    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|    +--- com.squareup.okhttp:okhttp:2.7.5
|    |    \--- com.squareup.okio:okio:1.6.0 -> 1.15.0
|    +--- io.grpc:grpc-android:1.16.1
|    |    \--- io.grpc:grpc-core:[1.16.1] -> 1.16.1
|    |         +--- io.grpc:grpc-context:1.16.1
|    |         +--- com.google.code.gson:gson:2.7 -> 2.8.0
|    |         +--- com.google.errorprone:error_prone_annotations:2.2.0
|    |         +--- com.google.code.findbugs:jsr305:3.0.2
|    |         +--- org.codehaus.mojo:animal-sniffer-annotations:1.17
|    |         +--- com.google.guava:guava:26.0-android
|    |         |    +--- org.checkerframework:checker-compat-qual:2.5.2
|    |         |    \--- com.google.j2objc:j2objc-annotations:1.1
|    |         +--- io.opencensus:opencensus-api:0.12.3
|    |         |    \--- com.google.errorprone:error_prone_annotations:2.2.0
|    |         \--- io.opencensus:opencensus-contrib-grpc-metrics:0.12.3
|    |              +--- com.google.errorprone:error_prone_annotations:2.2.0
|    |              \--- io.opencensus:opencensus-api:0.12.3 (*)
|    +--- io.grpc:grpc-okhttp:1.16.1
|    |    +--- io.grpc:grpc-core:[1.16.1] -> 1.16.1 (*)
|    |    +--- com.squareup.okhttp:okhttp:2.5.0 -> 2.7.5 (*)
|    |    \--- com.squareup.okio:okio:1.13.0 -> 1.15.0
|    +--- io.grpc:grpc-protobuf-lite:1.16.1
|    |    +--- io.grpc:grpc-core:1.16.1 (*)
|    |    +--- com.google.protobuf:protobuf-lite:3.0.1
|    |    \--- com.google.guava:guava:26.0-android (*)
|    \--- io.grpc:grpc-stub:1.16.1
|         \--- io.grpc:grpc-core:1.16.1 (*)
但问题是我根本无法排除它。如果我这样做了,我的应用程序将编译,但会在需要调用 Firestore 时立即崩溃。这是我的应用程序启动后。
我只是不明白。

最佳答案

要找出谁在使用“jetified-protobuf-lite-3.0.1.jar”,请使用这个
gradle app:dependencies
一些依赖还在使用旧版本的protobuf
你可以找到here当依赖项使用同一库的不同版本时该怎么办。

关于android - Firebase Android : Duplicate Protobuf classes found in modules,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63329045/

相关文章:

java - NativeScript HelloWorld build.gradle错误

android - 如何在sqlite中仅更新列为空?

android - 在 RecyclerView 中绘制空单元格

javascript - 如何在 https 云功能中检查身份验证?

java - 由于无法找到 Android 启动器类,无法在 Android 设备上运行 LibGDX 游戏

java - 在 gradle 和 maven 之间创建共同点

java - OnClick监听器Recyclerview打开不同的 Activity 来打开pdf文件

android - 调试 APK 以在不重新编译的情况下发布 APK

java - 如何在android中将多个图像上传到firebase?

firebase - 如何在服务器端访问dart中的firestore