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 class com.google.protobuf.DescriptorProtos #5997

Open
dpredovic opened this issue May 24, 2024 · 10 comments
Open

duplicate class com.google.protobuf.DescriptorProtos #5997

dpredovic opened this issue May 24, 2024 · 10 comments
Assignees
Labels
api: firestore type: bug Something isn't working

Comments

@dpredovic
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: 2023.3.1 p1
  • Firebase Component: firestore, storage, auth, perf, crashalytics, analytics
  • Component version: bom 33.0.0

[REQUIRED] Step 3: Describe the problem

protolite-well-known-types:18.0.0 contains "com.google.protobuf.DescriptorProtos", the same class as protobuf-javalite:4.27.0, resulting in the CheckDuplicatesRunnable failing:

Duplicate class com.google.protobuf.DescriptorProtos found in modules protobuf-javalite-4.27.0.jar -> protobuf-javalite-4.27.0 (com.google.protobuf:protobuf-javalite:4.27.0) and protolite-well-known-types-18.0.0.aar -> protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)

Steps to reproduce:

try building an app with libraries above

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

Relevant Code:

// TODO(you): code here to reproduce the problem
@lehcar09
Copy link
Contributor

Hi @dpredovic, thank you for reaching. Firebase uses protolite that includes the protolite-well-known-types module. To resolve the issue, you have to exclude the protolite-well-known-types module from the Firebase products.

app/build.gradle.kts

dependencies {
    implementation(platform("com.google.firebase:firebase-bom:33.0.0"))
    implementation("com.google.firebase:firebase-firestore") {
         exclude(group = "com.google.firebase", module = "protolite-well-known-types")
    }
    implementation("com.google.protobuf:protobuf-javalite:4.27.0")
}

That said, I’ll go ahead and close this issue. Let me know if there’s any misunderstanding and/or we need to re-open the issue for further investigation.

@dpredovic
Copy link
Author

Excluding the library fixes the build error, but leads to missing class at runtime:

 java.lang.RuntimeException: Internal error in Cloud Firestore (25.0.0).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:545)
at com.google.firebase.firestore.util.AsyncQueue$$ExternalSyntheticLambda3.run(D8$$SyntheticClass:0)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/type/LatLng;
at com.google.firestore.v1.Value.dynamicMethod(Value.java:1806)
at com.google.protobuf.GeneratedMessageLite.dynamicMethod(GeneratedMessageLite.java:290)
at com.google.protobuf.GeneratedMessageLite.buildMessageInfo(GeneratedMessageLite.java:360)
at com.google.protobuf.GeneratedMessageInfoFactory.messageInfoFor(GeneratedMessageInfoFactory.java:37)
at com.google.protobuf.ManifestSchemaFactory$CompositeMessageInfoFactory.messageInfoFor(ManifestSchemaFactory.java:126)
at com.google.protobuf.ManifestSchemaFactory.createSchema(ManifestSchemaFactory.java:33)
at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:68)
at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:82)
at com.google.protobuf.GeneratedMessageLite.makeImmutable(GeneratedMessageLite.java:203)
at com.google.protobuf.GeneratedMessageLite$Builder.buildPartial(GeneratedMessageLite.java:484)
at com.google.protobuf.GeneratedMessageLite$Builder.build(GeneratedMessageLite.java:490)
at com.google.firebase.firestore.model.ObjectValue.<init>(ObjectValue.java:60)
at com.google.firebase.firestore.model.MutableDocument.newInvalidDocument(MutableDocument.java:94)
at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.getAll(SQLiteRemoteDocumentCache.java:128)
at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.get(SQLiteRemoteDocumentCache.java:116)
at com.google.firebase.firestore.local.LocalDocumentsView.getBaseDocument(LocalDocumentsView.java:413)
at com.google.firebase.firestore.local.LocalDocumentsView.getDocument(LocalDocumentsView.java:92)
at com.google.firebase.firestore.local.LocalDocumentsView.getDocumentsMatchingDocumentQuery(LocalDocumentsView.java:292)
at com.google.firebase.firestore.local.LocalDocumentsView.getDocumentsMatchingQuery(LocalDocumentsView.java:268)
at com.google.firebase.firestore.local.QueryEngine.executeFullCollectionScan(QueryEngine.java:307)
at com.google.firebase.firestore.local.QueryEngine.getDocumentsMatchingQuery(QueryEngine.java:112)
at com.google.firebase.firestore.local.LocalStore.executeQuery(LocalStore.java:866)
at com.google.firebase.firestore.core.SyncEngine.initializeViewAndComputeSnapshot(SyncEngine.java:223)
at com.google.firebase.firestore.core.SyncEngine.listen(SyncEngine.java:210)
at com.google.firebase.firestore.core.EventManager.addQueryListener(EventManager.java:142)
at com.google.firebase.firestore.core.FirestoreClient.lambda$listen$7$com-google-firebase-firestore-core-FirestoreClient(FirestoreClient.java:181)
at com.google.firebase.firestore.core.FirestoreClient$$ExternalSyntheticLambda15.run(D8$$SyntheticClass:0)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$2(AsyncQueue.java:444)
at com.google.firebase.firestore.util.AsyncQueue$$ExternalSyntheticLambda4.call(D8$$SyntheticClass:0)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1(AsyncQueue.java:330)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:0)
```

@lehcar09 lehcar09 reopened this May 24, 2024
@lehcar09
Copy link
Contributor

Apologies about that. Per checking, the issue occurs in version protobuf-javalite:4.27.0. Based on Maven Protocol Buffers [Lite] Repository, 4.27.0 seems to be in beta version.

I tried using the protobuf-javalite:4.26.1 and I did not encounter build and/ or runtime issues. Aside from that, even not excluding the protolite-well-known-types from Firebase Firestore dependency, build and/ or runtime issues.

Here’s my update dependencies:
app/build.gradle.kts

    implementation(platform("com.google.firebase:firebase-bom:33.0.0"))
    implementation("com.google.firebase:firebase-messaging")
    implementation("com.google.firebase:firebase-firestore")

    implementation("com.google.protobuf:protobuf-javalite:4.26.1")

Could you check if that works with you as well?

@dpredovic
Copy link
Author

The old protobuf version works, no problem. I already downgraded, but we need a better solution.

@lehcar09
Copy link
Contributor

Thank you for your confirmation. I'll notify our engineers about this issue and see what we can do here.

In the meantime, I suggest using the version protobuf-javalite: 4.26.1.

@lehcar09 lehcar09 added api: performance type: bug Something isn't working and removed needs-attention labels May 28, 2024
@MarkDuckworth MarkDuckworth self-assigned this May 28, 2024
@rlazo rlazo assigned rlazo and unassigned MarkDuckworth May 28, 2024
@rlazo
Copy link
Collaborator

rlazo commented May 28, 2024

Hi @dpredovic thanks for raising this issue.

TL;DR; The latest version of protobuf-javalite (4.27) is not compatible with Firebase SDKs. Depend on an older version (4.26.x) while we fix the issue.

Here's the rundown of the problem.

  1. Older versions of the protobuf-javalite library did not include the DescriptorProto class in them.
  2. We, Firebase, worked around the issue by providing it ourselves in the protolite-well-known-types sdk (https://github.com/firebase/firebase-android-sdk/blob/master/protolite-well-known-types/src/main/proto/google/protobuf/descriptor.proto)
  3. In the latest release of protobuf-javalite from May 23 upstream included this change (protocolbuffers/protobuf@500c953#diff-7b118ca1a27fe212e2315ba1ab008be7de574c6eae4d52ace00e15869ea418a0) that adds that class to the library.
  4. This is causing the duplicated classes

We'll work on our end and release new versions of the affected SDKs that don't have this issue. In the meanwhile, the workaround is using an older version of protobuf-javalite.

I'll keep this issue open until the new versions are out.

Thanks again!

@NoyaD9
Copy link

NoyaD9 commented Jun 7, 2024

Any update on that one? I see the new protobuf 4.27.1 is there but the error seems to still be there

@daymxn
Copy link
Member

daymxn commented Jun 7, 2024

Hi @dpredovic thanks for raising this issue.

TL;DR; The latest version of protobuf-javalite (4.27) is not compatible with Firebase SDKs. Depend on an older version (4.26.x) while we fix the issue.

Here's the rundown of the problem.

  1. Older versions of the protobuf-javalite library did not include the DescriptorProto class in them.
  2. We, Firebase, worked around the issue by providing it ourselves in the protolite-well-known-types sdk (https://github.com/firebase/firebase-android-sdk/blob/master/protolite-well-known-types/src/main/proto/google/protobuf/descriptor.proto)
  3. In the latest release of protobuf-javalite from May 23 upstream included this change (protocolbuffers/protobuf@500c953#diff-7b118ca1a27fe212e2315ba1ab008be7de574c6eae4d52ace00e15869ea418a0) that adds that class to the library.
  4. This is causing the duplicated classes

We'll work on our end and release new versions of the affected SDKs that don't have this issue. In the meanwhile, the workaround is using an older version of protobuf-javalite.

I'll keep this issue open until the new versions are out.

Thanks again!

We should be able to fix this issue by removing the "extra" types we provide, and updating our protobuf dependency to 4.27+. Unfortunately, the removal of the extra types we provide is not the only breaking change that occurs between 3.0 and 4.0. Currently, updating our protobuf dependency to 4.27+ causes a variety of breaking changes across our ecosystem; changes that would require moderate overhead investigating and fixing. This is definitely something we're interested in doing, but we do not currently have the free cycles to handle it.

In the meantime, we'll leave this bug open until we get around to fixing this, and also so that folks can give their +1.

@ygnessin
Copy link

Hi @daymxn, any update on this issue? I see that #5999 is approved but not yet merged.

Will a fix be included in the next release?

Thank you so much for your attention to this issue!

@elevenfive
Copy link

elevenfive commented Sep 19, 2024

For anyone wondering it looks like the recent CVE from this week does not affect 4.26.x thankfully so folks can stay on that until this issue is fixed.

https://www.cve.org/CVERecord?id=CVE-2024-7254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants