Adding the OpenIa.Maui nuget (version 1.1.1) to a net10-android app breaks the build process:
<PackageReference Include="OpenIap.Maui" Version="1.1.1" />
The build process results in duplication errors like:
javac.exe error JAVAC0000: error: class string is already defined in class R
That is because the openiap nuget package includes google android bindings that are aready available through other nuget packages like Xamarin.GooglePlayServices.* (which are maui nugets, the xamarin name is misleading).
And for example including the nuget Xamarin.GooglePlayServices.Games.V2 will result in a duplication of these embedded libs.
So instead of fat bundling the google libs, add the existing matching nugets.
Workaround
To be able to build the android app using the 1.1.1 version of OpenIap I had to add this target to the dotnet 10 project:
<Target Name="RemoveOpenIapDuplicateAars" BeforeTargets="_ResolveLibraryProjectImports"
Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<ItemGroup>
<!-- Drop only OpenIap's bundled AARs that duplicate this app's existing bindings
(play-services base/basement/tasks via Xamarin.GooglePlayServices.*, transport-* via
Xamarin.Google.Android.DataTransport.*). play-services-location, billing*, and openiap*
are kept — nothing else provides them. StartsWith('play-services-base') covers basement too. -->
<AndroidAarLibrary Remove="@(AndroidAarLibrary)"
Condition="$([System.String]::Copy('%(Identity)').Contains('openiap.maui')) AND (
$([System.String]::Copy('%(Filename)').StartsWith('play-services-base')) OR
$([System.String]::Copy('%(Filename)').StartsWith('play-services-tasks')) OR
$([System.String]::Copy('%(Filename)').StartsWith('transport-')) )" />
<!-- OpenIap.Maui.Bindings.Android.aar embeds its own gson, duplicating the GoogleGson binding
pulled in transitively (R8: "com.google.gson.* defined multiple times"). Drop the standalone
GoogleGson AAR so only one gson is dexed; the embedded copy serves the Java consumers.
No C# code here uses Com.Google.Gson (we use System.Text.Json), so this is safe — but
confirm gson-dependent paths at runtime on device (sub-task 7). -->
<AndroidAarLibrary Remove="@(AndroidAarLibrary)"
Condition="$([System.String]::Copy('%(Identity)').ToLower().Contains('googlegson'))" />
</ItemGroup>
</Target>
But I'm still not sure the android app will run.
Adding the OpenIa.Maui nuget (version 1.1.1) to a net10-android app breaks the build process:
The build process results in duplication errors like:
That is because the openiap nuget package includes google android bindings that are aready available through other nuget packages like Xamarin.GooglePlayServices.* (which are maui nugets, the xamarin name is misleading).
And for example including the nuget
Xamarin.GooglePlayServices.Games.V2will result in a duplication of these embedded libs.So instead of fat bundling the google libs, add the existing matching nugets.
Workaround
To be able to build the android app using the 1.1.1 version of OpenIap I had to add this target to the dotnet 10 project:
But I'm still not sure the android app will run.