Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate classes jetified-protolite-well-known-types and protobuf-java #6359

Closed
CloudLevi opened this issue Oct 9, 2024 · 5 comments
Closed

Comments

@CloudLevi
Copy link

[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:

  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Android Studio Koala | 2024.1.1 Patch 2
  • Firebase Component: firestore, storage, auth, functions, remote config, messaging, crashlytics, analytics
  • Component version: BOM 33.4.0 (Also tested on 33.2.0)

[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 the build.gralde, the app is able to run, but firebase services fail immediately:

configurations {
    implementation.exclude module:'proto-google-common-protos'
    implementation.exclude module:'protolite-well-known-types'
    implementation.exclude module:'protobuf-lite'
    implementation.exclude module:'protobuf-javalite'
}

Steps to reproduce:

Try to build the project with firebase APIs and google cloud pubsub.

Relevant Code:

Versions of firebase APIs used:

    implementation platform('com.google.firebase:firebase-bom:33.4.0')
    //firestore integration
    implementation 'com.google.firebase:firebase-firestore'
    //firebase storage (files)
    implementation 'com.google.firebase:firebase-storage'
    //firebase auth
    implementation 'com.google.firebase:firebase-auth'
    //firebase-functions
    implementation 'com.google.firebase:firebase-functions'
    //firebase remote config
    implementation 'com.google.firebase:firebase-config'
    //firebase messaging
    implementation 'com.google.firebase:firebase-messaging'
    implementation("com.google.firebase:firebase-crashlytics")
    implementation("com.google.firebase:firebase-analytics")

Google Cloud PubSub version used:

    implementation platform('com.google.cloud:libraries-bom:26.47.0')
    implementation 'com.google.cloud:google-cloud-pubsub'

Build error output attached in a file: firebase_conflict_error_output.txt

@lehcar09
Copy link
Contributor

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!

@daymxn
Copy link
Member

daymxn commented Oct 10, 2024

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.

@CloudLevi
Copy link
Author

@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.

Excluding 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)

Excluding 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)

Excluding 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)

Excluding 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.

@davidmotson
Copy link
Collaborator

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?

@CloudLevi
Copy link
Author

CloudLevi commented Oct 22, 2024

@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

@firebase firebase locked and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants