googlesamples / sceneform-samples

Sceneform samples for 3D rendering for ARCore in Java.
https://developers.google.com/ar/develop/java/sceneform/
Apache License 2.0
87 stars 22 forks source link

[Q] Gradle issue with sceneform - Program type already present: com.google.ar.schemas.lull #4

Closed Kamil-Kacprzak closed 4 years ago

Kamil-Kacprzak commented 4 years ago

I am working on a project that will have a 3D model viewer in one fragment. In order to do so, I decided to use sceneform.

I downloaded sceneform plugin into Adnroid studio, downloaded and extracted sdk from Github, and I also copied libsceneform_runtime_schemas library into my project. I've added to my sceneform buil.gradle file line

implementation files("../libs/libsceneform_runtime_schemas.jar")

but that results in an error:

Program type already present: com.google.ar.schemas.lull.AabbDef

It is worth noticing that this is the first file in the jar under this path - which probably means that there will be more collisions.

If I'd try not to implement this library, then I get an error:

error: package com.google.ar.schemas.sceneform does not exist

I am using ar:core:1.17.0, and minSdkVersion 24 in sceneform gradle. I've cleaned and rebuilt the project, Invalidate Caches/Restart, and added multiDexEnabled- although I am not sure if I did it correctly. By using gradlew sceneform:dependencies I didn't find mentioned file.

I don't know how I can move forward, any help is much appreciated. If I can provide additional information, please let me know.

I've also tried to work with

implementation files("../libs/libsceneform_runtime_schemas.jar"){
   exclude ...
}

But I couldn't make it work. I wonder if that could be my solution.

Also, why does it try to implement this class since it already exists? Shouldn't there be some sort of check for that?

Kamil-Kacprzak commented 4 years ago

I solved my problem by restoring my project from repo to the last moment before including sceneform, and I proceeded with all of the steps again; Gradle dependencies, java 8, min SDK version, copying scenformscr and sceneformux to my project again, and lastly - upgrading all classes to AndroidX.
I don't know what went wrong before but this time it works like a charm.