+1 vote
by (460 points)
recategorized by

Hello,

I am trying to make an Android build using the Unity XR SDK v2.0.1 and Unity 2021.1.28f1. However I stumbled upon an error, which causes the build to fail:
Duplicate class errors

I found out that pxr_api-release-runtime.jar contains gson 2.8.0. I am also using Sentry . io, which I found uses gson 2.8.5. They however have the gson.dll included with their unity package, rather than having it inside the .aar library.

How could I resolve this issue by having both Pico and SentryIO work in the same unity project? I need to get rid of the gson duplicate classes errors. I think you should add gson.dll with the unity package rather than have it packed inside the .aar.

Any help is much appreciated,
Thanks!

1 Answer

–1 vote
by (55.5k points)

Dear developer,

We tested it with Unity XR SDK v2.0.1 and SentryIO and reproduce the problem.

And then,we delete Packages/io.sentry.unity/Plugins/Android/Sentry/gson-2.8.5.jar and the project builded successfully.

enter image description here

In the meanwhile,when the project is running,the SentryIO can capture the Error normally.
enter image description here

Hope it helps you.

by (460 points)

Dear support,

I am glad you were able to reproduce the issue.

However, removing a .dll of another library that depends on that .dll is not a solution. You are correct that this enables us to make builds. But it also means that Sentry becomes unable to capture exceptions in cases where the Unity player crashes or exception occurs in native code, which cannot be handled by .NET.

In order to ensure that Pico works with other 3rd party libraries, you must handle dependencies like these (LitJson in the example) correctly. Sentry has done it correctly.

Instead of having the dependency packed in the pxrapi-release.aar, it should be a separate file next to the pxrapi-release.aar, which you can then reference.

Best

by (55.5k points)

Thanks for your valuable feedback.

...