If you try to consume the package Xamarin.AndroidX.DataStore.Preferences, you get the following error:
JAVA0000: Error in C:\.tools\.nuget\packages\xamarin.androidx.datastore.core.jvm\1.1.1.2\buildTransitive\net8.0-android34.0\..\..\jar\androidx.datastore.datastore-core-jvm.jar:androidx/datastore/core/Actual_jvmKt.class:
JAVA0000: Type androidx.datastore.core.Actual_jvmKt is defined multiple times:
- C:\.tools\.nuget\packages\xamarin.androidx.datastore.core.jvm\1.1.1.2\buildTransitive\net8.0-android34.0\..\..\jar\androidx.datastore.datastore-core-jvm.jar:androidx/datastore/core/Actual_jvmKt.class,
- obj\Release\net8.0-android\lp\30\jl\classes.jar:androidx/datastore/core/Actual_jvmKt.class
This is because through the complex set of dependencies, you end up using these 2 packages:
Xamarin.AndroidX.DataStore.Core.Android
Xamarin.AndroidX.DataStore.Core.Jvm
These packages contain the same Java code, the Android one seems to be a superset of the Jvm one:
Thus we believe the solution is to redirect the Jvm package to the Android one. That is, anytime the Jvm package is requested we are going to give it the Android one instead.
We will accomplish this via:
Adding Xamarin.AndroidX.DataStore.Core.Android as a dependency of Xamarin.AndroidX.DataStore.Core.Jvm. This means anytime Jvm is requested Android will also be added.
Removing the Jvm Java library and its bindings from Xamarin.AndroidX.DataStore.Core.Jvm so that it will no longer duplicate the bindings and Java library in Android.
With these changes, we no longer see the conflict errors when consuming the Xamarin.AndroidX.DataStore.Preferences* packages in the ExtendedTests suite.
Additionally, bump all the androidx.datastore packages so that this new version will get picked up.
Fixes: https://github.com/xamarin/GooglePlayServicesComponents/issues/880
If you try to consume the package
Xamarin.AndroidX.DataStore.Preferences
, you get the following error:This is because through the complex set of dependencies, you end up using these 2 packages:
Xamarin.AndroidX.DataStore.Core.Android
Xamarin.AndroidX.DataStore.Core.Jvm
These packages contain the same Java code, the
Android
one seems to be a superset of theJvm
one:Thus we believe the solution is to redirect the
Jvm
package to theAndroid
one. That is, anytime theJvm
package is requested we are going to give it theAndroid
one instead.We will accomplish this via:
Xamarin.AndroidX.DataStore.Core.Android
as a dependency ofXamarin.AndroidX.DataStore.Core.Jvm
. This means anytimeJvm
is requestedAndroid
will also be added.Jvm
Java library and its bindings fromXamarin.AndroidX.DataStore.Core.Jvm
so that it will no longer duplicate the bindings and Java library inAndroid
.With these changes, we no longer see the conflict errors when consuming the
Xamarin.AndroidX.DataStore.Preferences*
packages in theExtendedTests
suite.Additionally, bump all the
androidx.datastore
packages so that this new version will get picked up.