Closed CloudLevi closed 3 weeks ago
Hi @CloudLevi, thank you for reaching out. I was able to reproduce the issue. I'll notify our engineers about this and see what we do here. Thanks!
This is a known issue when using protobuf-java
and protobuf-javalite
at the same time. See protobuf/issues/8104 for context.
You'll need to exclude either javalite or protobuf-java.
@daymxn thank you for your response. The thing is, I've tried many combinations of excluding modules and still can't get a successful build. I'll list some examples of what I've tried.
protobuf-javalite
Code:
configurations {
implementation.exclude module:'protobuf-javalite'
}
Result: Build fails, seems to be caused by a conflict between com.google.api.grpc:proto-google-common-protos
and com.google.firebase:protolite-well-known-types
(see file: exclude_javalite_only.txt)
protobuf-javalite
and protolite-well-known-types
Code:
configurations {
implementation.exclude module:'protobuf-javalite'
implementation.exclude module:'protolite-well-known-types'
}
Result: Build succeeds, but app immediately crashes due to firestore failing to initialize. (see file: exclude_javalite_and_well_known_types.txt)
protobuf-javalite
and proto-google-common-protos
Code:
configurations {
implementation.exclude module:'protobuf-javalite'
implementation.exclude module:'proto-google-common-protos'
}
Result: Build fails due to conflicts between protobuf-java
and com.google.firebase:protolite-well-known-types
. (see file: exclude_javalite_and_google_common_protos.txt)
protobuf-java
Code:
configurations {
implementation.exclude module:'protobuf-java'
}
Result: build fails due to missing classes for pubsub (these are the ones I used in the project, I'm sure there are others):
class file for com.google.protobuf.MessageOrBuilder not found
class file for com.google.protobuf.GeneratedMessageV3 not found
I understand that most likely the answer lies in one of these configurations, but for now I couldn't find a combination with which the app will build and there will be no runtime errors. Any help would be appreciated, thank you.
I was able to reproduce this, however, in doing so I ran into something. I don't think com.google.cloud:google-cloud-pubsub is meant for use on Android. I think its meant for a server environment. Can you verify that it is usable in Android?
@davidmotson you might be right... It's quite difficult to find valid information on this topic, but here's what I found.
Even though it seems like using pubsub on Android is possible, it's likely not the best approach. It would be better to connect it to Android via Firebase Messaging, as suggested here: https://stackoverflow.com/questions/75983750/pub-sub-on-android-via-google-sign-in
Also, I found this in connection to Firebase and PubSub: https://firebase.google.com/docs/functions/pubsub-events?gen=2nd
Here are some examples of pubsub usage on Android: https://github.com/hofstede-matheus/PubSubAndroidExample https://github.com/androidthings/weatherstation
I will investigate this approach and can report back, but it seems for now this particular issue of conflicts can be closed
[READ] Step 1: Are you in the right place?
Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
When using firebase APIs with
com.google.cloud:google-cloud-pubsub
, I am not able to build the project due to many duplicate class errors. If I add the following exclusions in thebuild.gralde
, the app is able to run, but firebase services fail immediately:Steps to reproduce:
Try to build the project with firebase APIs and google cloud pubsub.
Relevant Code:
Versions of firebase APIs used:
Google Cloud PubSub version used:
Build error output attached in a file: firebase_conflict_error_output.txt