Reputation: 481
Adding Pub/Sub library with Firestore causes duplicate class issues. Firestore without Pub/Sub working perfectly fine with the required functionality. I don't want to exclude anything from Firestore and Pub/Sub dependencies to fix conflicts as both have some kind of implementation conflict so as per my understanding nothing to exclude from both libraries to work properly with their dependencies. Please help me to fix this issue.
Build.gradle
apply plugin: 'com.android.application'
apply plugin: "com.google.protobuf"
android {
namespace 'com.example.lottieanimation'
compileSdk 33
defaultConfig {
applicationId "com.example.lottieanimation"
minSdk 28
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
pickFirst 'lib/*/libc++_shared.so'
exclude 'META-INF/*'
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
//implementation project(path: ':PubSubSync')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.firebase:firebase-firestore:24.4.5'
implementation 'com.google.firebase:firebase-auth:21.2.0'
implementation 'com.google.auth:google-auth-library-oauth2-http:1.16.0'
implementation('com.google.cloud:google-cloud-pubsub:1.123.7') {
exclude group: 'org.apache.httpcomponents'
}
}
Errors: There is a big list of duplicate class errors, just mentioning a few. You can recreate it on your end.
Duplicate class com.google.api.Advice found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.Advice$1 found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.Advice$Builder found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AdviceOrBuilder found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AnnotationsProto found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthProto found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthProvider found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthProvider$1 found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthProvider$Builder found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthProviderOrBuilder found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthRequirement found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthRequirement$1 found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthRequirement$Builder found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthRequirementOrBuilder found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.Authentication found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.Authentication$1 found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.Authentication$Builder found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthenticationOrBuilder found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthenticationRule found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthenticationRule$1 found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0) Duplicate class com.google.api.AuthenticationRule$Builder found in modules proto-google-common-protos-2.14.3 (com.google.api.grpc:proto-google-common-protos:2.14.3) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)
Upvotes: 0
Views: 173
Reputation: 522
It looks like this is a known issue with two workarounds currently available to try out:
protolite-well-known-types
dependency from the Firebase libraries in your build configuration. There is an example for how to do this in a thread with a similar question here.proto-well-known-types
from the pubsub libraries and the Firestore SDK to match up and eliminate the duplicate class conflict. Alternatively you could also try adjusting the version of the pub sub libraries you are using.Also please see this closed GitHub issue that discusses a very similar issue and workaround as 1.
Upvotes: 1