Skip to content

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

Open
@Vangaorth

Description

@Vangaorth

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2019.4.21
  • Firebase Unity SDK version: 7.1.0
  • Source you installed the SDK: Unity Package Manager
  • Problematic Firebase Component: Cloud Messaging
  • Other Firebase Components in use: App (Core), Crashlytics, Analytics
  • Additional SDKs you are using: Third party remote assistance library (as .AAR + dependencies in mainTemplate.gradle)
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: iOS and Android
  • Scripting Runtime: IL2CPP

[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

  • Create a new Unity Android project, add the Firebase Cloud Messaging (7.1.0) using the Unity Package Manager (when asked from the External Dependency Manager, specify "Enable")
  • In Player Settings -> Publishing Settings, specifiy that you want to use a custom mainTemplate.gradle
  • Add "implementation "com.google.ar.sceneform:core:1.17.1" to the dependencies of mainTemplate.gradle
  • Build an APK

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions