firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
835 stars 431 forks source link

Gradle fails with Duplicate Classes error when using Firebase Cloud Messaging and sceneform:core in mainTemplate.gradle #984

Open Vangaorth opened 3 years ago

Vangaorth commented 3 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

When using the Firebase Cloud Messaging (through the Unity Package Manager), having a custom mainTemplate.gradle where a third party dependencies to com.google.ar.sceneform:core is specified (implementation "com.google.ar.sceneform:core:1.17.1"), the build process fails during "Building GRadle project" phase with the following errors:

java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.google.flatbuffers.Constants found in modules classes.jar (com.google.ar.sceneform:sceneform-base:1.17.1) and classes.jar (com.google.firebase:firebase-messaging-unity:7.1.0)
Duplicate class com.google.flatbuffers.FlatBufferBuilder found in modules classes.jar (com.google.ar.sceneform:sceneform-base:1.17.1) and classes.jar (com.google.firebase:firebase-messaging-unity:7.1.0)
Duplicate class com.google.flatbuffers.FlatBufferBuilder$ByteBufferFactory found in modules classes.jar (com.google.ar.sceneform:sceneform-base:1.17.1) and classes.jar (com.google.firebase:firebase-messaging-unity:7.1.0)
Duplicate class com.google.flatbuffers.FlatBufferBuilder$HeapByteBufferFactory found in modules classes.jar (com.google.ar.sceneform:sceneform-base:1.17.1) and classes.jar (com.google.firebase:firebase-messaging-unity:7.1.0)
Duplicate class com.google.flatbuffers.Struct found in modules classes.jar (com.google.ar.sceneform:sceneform-base:1.17.1) and classes.jar (com.google.firebase:firebase-messaging-unity:7.1.0)
Duplicate class com.google.flatbuffers.Table found in modules classes.jar (com.google.ar.sceneform:sceneform-base:1.17.1) and classes.jar (com.google.firebase:firebase-messaging-unity:7.1.0)
Duplicate class com.google.flatbuffers.Utf8 found in modules classes.jar (com.google.ar.sceneform:sceneform-base:1.17.1) and classes.jar (com.google.firebase:firebase-messaging-unity:7.1.0)
Duplicate class com.google.flatbuffers.Utf8Safe found in modules classes.jar (com.google.ar.sceneform:sceneform-base:1.17.1) and classes.jar (com.google.firebase:firebase-messaging-unity:7.1.0)

This does not happen in a native Android Studio project (no Unity involved), where the app.gradle dependencies are as follows:

implementation "com.google.ar.sceneform:core:1.17.1"
implementation platform('com.google.firebase:firebase-bom:26.6.0')
implementation 'com.google.firebase:firebase-messaging'

Steps to reproduce:

Or

vimanyu commented 3 years ago

Thank you for providing details and clear steps for reproduction. I can see this error in our messaging quickstart example in Unity 2020 and Firebase Unity plugins 7.1.0. Filing this as a bug.