objectbox-java: FlatBuffers version conflicts with other library

Edit: this is due to FlatBuffers versions conflicting. See the comment below for details and potential workarounds. https://github.com/objectbox/objectbox-java/issues/894#issuecomment-674734559


@greenrobot-team I have the same issue of duplicated dependencies (between ObjectBox and GoogleArCore Sceneform):

Duplicate class com.google.flatbuffers.Constants found in modules jetified-flatbuffers-java-1.12.0.jar (com.google.flatbuffers:flatbuffers-java:1.12.0) and jetified-sceneform-base-1.15.0-runtime.jar (com.google.ar.sceneform:sceneform-base:1.15.0)
Duplicate class com.google.flatbuffers.FlatBufferBuilder found in modules jetified-flatbuffers-java-1.12.0.jar (com.google.flatbuffers:flatbuffers-java:1.12.0) and jetified-sceneform-base-1.15.0-runtime.jar (com.google.ar.sceneform:sceneform-base:1.15.0)
Duplicate class com.google.flatbuffers.FlatBufferBuilder$ByteBufferFactory found in modules jetified-flatbuffers-java-1.12.0.jar (com.google.flatbuffers:flatbuffers-java:1.12.0) and jetified-sceneform-base-1.15.0-runtime.jar (com.google.ar.sceneform:sceneform-base:1.15.0)
Duplicate class com.google.flatbuffers.FlatBufferBuilder$HeapByteBufferFactory found in modules jetified-flatbuffers-java-1.12.0.jar (com.google.flatbuffers:flatbuffers-java:1.12.0) and jetified-sceneform-base-1.15.0-runtime.jar (com.google.ar.sceneform:sceneform-base:1.15.0)
Duplicate class com.google.flatbuffers.Struct found in modules jetified-flatbuffers-java-1.12.0.jar (com.google.flatbuffers:flatbuffers-java:1.12.0) and jetified-sceneform-base-1.15.0-runtime.jar (com.google.ar.sceneform:sceneform-base:1.15.0)
Duplicate class com.google.flatbuffers.Table found in modules jetified-flatbuffers-java-1.12.0.jar (com.google.flatbuffers:flatbuffers-java:1.12.0) and jetified-sceneform-base-1.15.0-runtime.jar (com.google.ar.sceneform:sceneform-base:1.15.0)
Duplicate class com.google.flatbuffers.Utf8 found in modules jetified-flatbuffers-java-1.12.0.jar (com.google.flatbuffers:flatbuffers-java:1.12.0) and jetified-sceneform-base-1.15.0-runtime.jar (com.google.ar.sceneform:sceneform-base:1.15.0)
Duplicate class com.google.flatbuffers.Utf8Safe found in modules jetified-flatbuffers-java-1.12.0.jar (com.google.flatbuffers:flatbuffers-java:1.12.0) and jetified-sceneform-base-1.15.0-runtime.jar (com.google.ar.sceneform:sceneform-base:1.15.0)

If I follow the solution of @dpproduction everything works right. I mean adding:

 implementation ("io.objectbox:objectbox-android:$objectboxVersion"){
        exclude group: 'com.google.flatbuffers', module: 'flatbuffers-java'
    }
    annotationProcessor "io.objectbox:objectbox-processor:$objectboxVersion"

and removing the "apply plugin: 'io.objectbox'".

However I’m afraid of what you said of avoid removing the apply plugin.

I tried to add apply plugin: ‘io.objectbox’ in every ways (after dependencies block, at the beggining of the build.gradle app file, after the apply plugin: ‘com.android.application’) but nothing worked. Just removing the apply plugin.

Is there any solutions? What does it happen if I haven’t the apply plugin? The ObjectBox library will work with errors?

Thanks!!

_Originally posted by @nicodubi in https://github.com/objectbox/objectbox-java/issues/479#issuecomment-669634048_

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 25 (11 by maintainers)

Most upvoted comments

@tbikash62 The project you link to does not include ObjectBox. That the Sceneform SDK from Google includes a not repackaged FlatBuffers version is known and not something we, the ObjectBox team, can fix.

The next update will ship without the FlatBuffers dependency. Instead the FlatBuffers Java code version this library uses is copied to a different package name.

This will make it possible for user (your) code to use any other version of FlatBuffers Java library and flatc generated code. And prevent conflicts with other libraries not properly repackaging FlatBuffers like above.