mapbox / mapbox-unity-sdk

Mapbox Unity SDK - https://www.mapbox.com/unity/
Other
721 stars 214 forks source link

Android build duplicate classes #1564

Closed highpockets closed 4 years ago

highpockets commented 4 years ago

Note: If this is a bug or support ticket, please provide the following information:

Include Firebase SDK and MapBox SDK in the same project, build to Android and there are several errors reporting multiple duplicate classes found in modules classes.jar (:androidx.core.core-1.0.0:) and classes.jar (:support-compat-25.1.0:). The androidx.core.core-1.0.0 is from the Firebase SDK (it is the new support library) and the support-compat-25.1.0 is from the Mapbox SDK..

My log file is almost exactly the same as the one from the link below which is from the Facebook SDK. The only difference is the support library versions are not the same.

https://github.com/facebook/facebook-sdk-for-unity/issues/386

Will you guys be refactoring to the androidx support library??

EDIT: Or will you guys be using Android/Play Service Resolver rather than redistributing Java libraries??

At the moment, the workaround, as mentioned in the link above, is to export the project from Unity to Android Studio and delete implementation of the support library in question from build.gradle and also removing a line in the AndroidManifest file.. This is not the most comfortable solution as it has to be done every time I do a test build.

EDIT: I have also created an issue with the Firebase SDK here at the link below, but I'm going to close it now since they Google Play Services requires AndroidX now and that is the support library that firebase is using. https://github.com/firebase/quickstart-unity/issues/607

thalkz commented 4 years ago

Hi @highpockets

I think I found a simpler workaround that does not require export to Android Studio.

The issue is that Mapbox includes Android support 25.1.0 packages into Gradle and that Firebase imports AndroidX packages at the same time.

Mapbox actually includes the .aar files for Android support 25.1.0 into the package. Simply removing all `-25.1.0.aarfiles fromAssets/Mapbox/Core/Plugins/Android/` prevents thoses files to be added to Gradle and resolves the conflict.

Hope it helps !

Asgarde commented 4 years ago

I tested your solution and it works fine. You are a GOD. Thanks a lot Thalkz.

highpockets commented 4 years ago

Hi @Thalkz,

Yes, that is a much easier and less painful approach. I'd imagine it would be best for Mapbox SDK to be updated to use AndroidX - or better yet the android resolver. Anyhow, I'll close this now even though both solutions are hacks.

gradus0 commented 2 years ago

Hi @highpockets

I think I found a simpler workaround that does not require export to Android Studio.

The issue is that Mapbox includes Android support 25.1.0 packages into Gradle and that Firebase imports AndroidX packages at the same time.

Mapbox actually includes the .aar files for Android support 25.1.0 into the package. Simply removing all `-25.1.0.aarfiles fromAssets/Mapbox/Core/Plugins/Android/` prevents thoses files to be added to Gradle and resolves the conflict.

Hope it helps !

man, you saved my life :)

fredericosa commented 1 year ago

thalkz, thanks a lot.