android - Firebase Android:在模块中发现重复的 Protobuf 类
问题描述
因此,我在 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 时立即崩溃。这是我的应用程序启动后。
我只是不明白。
解决方案
推荐阅读
- ios - 在即将推出的 iPhone 发布之前从哪里获得 iOS 设备硬件字符串?
- android - 带有蓝牙 5 的 AltBeacon 库(信标可检测范围)
- html - 在 Bootstrap 中,如何将导航栏链接向右对齐?
- python - 在 python 中使用正则表达式从文本文件中提取特定字符串
- java - 为什么mousePress不做任何事情?
- javascript - Javascript - 函数,缺少参数
- python-3.x - 将pynput与pyinstaller一起使用时出错
- angular - GravityForms - 通过 GF API(后端)使用 Google Recaptcha 发布表单
- python - 获取groupby中的对应值
- .net - .NET Core 依赖注入以注入多个依赖项