Skip to content

duplicate class com.google.protobuf.DescriptorProtos #5997

Closed

Description

@dpredovic

[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

Activity

  1. lehcar09 commented on May 24, 2024

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

  2. dpredovic commented on May 24, 2024

    @dpredovic
    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)
    ```
    
  3. lehcar09 commented on May 24, 2024

    @lehcar09
    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?

  4. dpredovic commented on May 24, 2024

    @dpredovic
    Author

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

  5. lehcar09 commented on May 28, 2024

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

  6. added
    type: bug
    and removed on May 28, 2024
  7. 37 remaining items

  8. jacek-marchwicki commented on Sep 29, 2025

    @jacek-marchwicki

    🚨 A word of caution regarding the solution from @ayushi-sk: Removing com.google.firebase:protolite-well-known-types can lead to app crashes. This library provides a crucial communication layer between Firebase and Google's servers. If you apply this fix, you must thoroughly test all Firebase features in your app to ensure they don't cause crashes or unexpected behavior.

  9. mehdiyari commented on Oct 16, 2025

    @mehdiyari

    I don't see any safe solution for now (excluding options that could cause runtime crashes or using a new version that would cause build-time errors). It's better to use a version that is compatible with both of these libraries.

    I'm using these two, and they are working fine together.

    protobufVersion = "4.26.1"
    firebaseBomVersion = "34.4.0"
    
  10. daniel-waiguru commented on Oct 28, 2025

    @daniel-waiguru

    Are there any plans to fix this issue?

  11. zenyagami commented on Dec 26, 2025

    @zenyagami

    Any update on this? removing the well-know classes will cause runtime crashes using firestore.

  12. nuhkoca commented on Jan 11, 2026

    @nuhkoca

    Up

  13. orcuns commented on Jan 28, 2026

    @orcuns

    I have the same issue!
    protobufVersion = "4.26.1" is the only way it works

  14. wantroba commented on Feb 4, 2026

    @wantroba

    Same problem here. The strangest thing is that it started without me making any changes to the project.

    What I did was add this snippet to the beginning of the app/build.grade file, right after the plugins section:

    configurations.all {
        resolutionStrategy {
            force "com.google.protobuf:protobuf-javalite:4.26.1"
        }
    }
    
  15. Uma1r commented on Apr 1, 2026

    @Uma1r

    Is there an update on this? Adding protobuf is breaking firestore for us and if exclusion for protolite-well-known-types is not done then the project won't compile due to duplicate class errors.

    System.err               java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/type/LatLng;
    System.err               	at com.google.firestore.v1.Value.dynamicMethod(Value.java:2696)
    System.err               	at com.google.protobuf.GeneratedMessageLite.buildMessageInfo(GeneratedMessageLite.java:358)
    System.err               	at com.google.protobuf.GeneratedMessageInfoFactory.messageInfoFor(GeneratedMessageInfoFactory.java:37)
    System.err               	at com.google.protobuf.ManifestSchemaFactory$CompositeMessageInfoFactory.messageInfoFor(ManifestSchemaFactory.java:106)
    System.err               	at com.google.protobuf.ManifestSchemaFactory.createSchema(ManifestSchemaFactory.java:33)
    System.err               	at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:54)
    System.err               	at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:69)
    System.err               	at com.google.protobuf.GeneratedMessageLite.makeImmutable(GeneratedMessageLite.java:209)
    System.err               	at com.google.protobuf.GeneratedMessageLite$Builder.buildPartial(GeneratedMessageLite.java:482)
    System.err               	at com.google.protobuf.GeneratedMessageLite$Builder.build(GeneratedMessageLite.java:488)
    System.err               	at com.google.firebase.firestore.model.Values.<clinit>(Values.kt:39)
    System.err               	at com.google.firebase.firestore.model.Values.encodeAnyValue(Values.kt:718)
    System.err               	at com.google.firebase.firestore.UserDataReader.parseScalarValue(UserDataReader.java:406)
    System.err               	at com.google.firebase.firestore.UserDataReader.parseData(UserDataReader.java:282)
    System.err               	at com.google.firebase.firestore.UserDataReader.parseList(UserDataReader.java:314)
    System.err               	at com.google.firebase.firestore.UserDataReader.parseData(UserDataReader.java:280)
    System.err               	at com.google.firebase.firestore.UserDataReader.convertAndParseFieldData(UserDataReader.java:217)
    System.err               	at com.google.firebase.firestore.UserDataReader.parseQueryValue(UserDataReader.java:206)
    System.err               	at com.google.firebase.firestore.Query.parseFieldFilter(Query.java:448)
    System.err               	at com.google.firebase.firestore.Query.parseFilter(Query.java:485)
    System.err               	at com.google.firebase.firestore.Query.where(Query.java:400)
    System.err               	at com.google.firebase.firestore.Query.whereArrayContainsAny(Query.java:297)
    System.err               Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.type.LatLng" on path: DexPathList[[zip file "/data/app/~~mdJkp1BNNA8krqk7Uk7Geg==/com.sample.app
    
  16. AhmedGarhy commented on Apr 14, 2026

    @AhmedGarhy

    I've tried the below configuration, and it worked!

    To avoid conflicts with protobuf-javalite and protolite-well-known-types, explicitly exclude them from both the Firebase BoM and firebase-perf dependencies.

    implementation(platform(libs.firebase.bom)) {
        exclude group: "com.google.protobuf", module: "protobuf-javalite"
        exclude group: "com.google.firebase", module: "protolite-well-known-types"
    }
    
    implementation(libs.firebase.perf) {
        exclude group: "com.google.protobuf", module: "protobuf-javalite"
        exclude group: "com.google.firebase", module: "protolite-well-known-types"
    }
    
    

    Additionally, the ProGuard rule ensures that fields in classes extending GeneratedMessageLite are retained, preventing runtime issues caused by code shrinking.

    -keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
        <fields>;
    }
    
  17. dconeybe commented on Oct 8, 2026

    @dconeybe
    Contributor

    Update: Firebase Android BoM version 35.0.0 (released October 07, 2026) includes #8580 which upgrades the gRPC and protobuf dependencies to their latest versions. This may fix the problems reported in this issue. Please try upgrading and report your findings.

  18. solamour commented on Oct 10, 2026

    @solamour

    28. Update: Firebase Android BoM version 35.0.0 (released October 07, 2026) includes #8580 which upgrades the gRPC and protobuf dependencies to their latest versions. This may fix the problems reported in this issue. Please try upgrading and report your findings.

    I've been stuck with protobuf-javalite = "4.26.1" because anything more recent gave me "duplicate class" error.
    Firebase BoM 35.0.0 solved the issue, at least for me. Curious to know how it works for others.

  19. orcuns commented on Oct 15, 2026

    @orcuns

    We've been stuck with protobuf-javalite = "4.26.1" for ages too. Firebase BoM 35.0.0 also solved the issue on our side.
    Thanks..

  20. dlarocque commented on Oct 20, 2026

    @dlarocque
    Contributor

    I will be closing this issue after confirmation that 35.0.0 solved the issue for multiple users.

  21. locked and limited conversation to collaborators on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: firestoretype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions