Android framework version
net9.0-android
Affected platform version
.NET SDK 9.0.316, macOS 15 (Apple Silicon)
Description
Xamarin.Google.MLKit.BarcodeScanning includes the Google Maven artifact com.google.mlkit:barcode-scanning:17.3.0 twice, which produces XA4301 duplicate-native-library warnings in every Android build that references the package (directly or transitively, e.g. via BarcodeScanning.Native.Maui):
obj/Debug/net9.0-android36.0/lp/260/jl/jni/arm64-v8a/libbarhopper_v3.so : warning XA4301: APK already contains the item lib/arm64-v8a/libbarhopper_v3.so; ignoring.
obj/Debug/net9.0-android36.0/lp/260/jl/jni/arm64-v8a/libbarhopper_v3.so : warning XA4301: APK already contains the item lib/arm64-v8a/libbarhopper_v3.so; ignoring.
The two copies come from the same NuGet package through two different mechanisms:
- The AAR embedded in the package itself:
lib/net9.0-android35.0/barcode-scanning.aar (extracted to obj/.../lp/228 in my build).
- The same artifact downloaded again at build time by
Xamarin.Build.Download: buildTransitive/net9.0-android35.0/Xamarin.Google.MLKit.BarcodeScanning.targets declares a XamarinBuildDownload item for https://dl.google.com/dl/android/maven2/com/google/mlkit/barcode-scanning/17.3.0/barcode-scanning-17.3.0.aar (extracted to obj/.../lp/260).
Mapping evidence from obj/Debug/net9.0-android36.0/libraryimports.cache:
lp/228 <- ~/.nuget/packages/xamarin.google.mlkit.barcodescanning/117.3.0.3/lib/net8.0-android34.0/barcode-scanning.aar
lp/260 <- ~/Library/Caches/XamarinBuildDownload/barcodescanning-17.3.0/barcodescanning-17.3.0.aar
On top of that, the targets file adds the downloaded AAR to the item group twice (identical consecutive lines), which is why the XA4301 warning is emitted twice per ABI:
<ItemGroup>
<XamarinBuildDownloadAndroidAarLibrary Include="$(XamarinBuildDownloadDir)barcodescanning-17.3.0\barcodescanning-17.3.0.aar" />
<XamarinBuildDownloadAndroidAarLibrary Include="$(XamarinBuildDownloadDir)barcodescanning-17.3.0\barcodescanning-17.3.0.aar" />
</ItemGroup>
I verified the same double-inclusion (embedded lib/**/barcode-scanning.aar + XamarinBuildDownload of the same artifact, with the doubled item line) is present in the latest release 117.3.0.8, in both the net9.0-android35.0 and net10.0-android36.0 targets, so all currently shipping versions are affected (checked 117.3.0.3 and 117.3.0.8).
Expected: the artifact is included once — either embedded in lib/ or fetched via XamarinBuildDownload, not both — and the XamarinBuildDownloadAndroidAarLibrary item is not duplicated inside the targets.
Related: xamarin/GooglePlayServicesComponents#819 reported the same warnings; it was closed without the source of the duplication being identified.
Steps to Reproduce
dotnet new maui
- Add
<PackageReference Include="Xamarin.Google.MLKit.BarcodeScanning" Version="117.3.0.8" /> (or BarcodeScanning.Native.Maui, which depends on it)
dotnet build -f net9.0-android
- Observe the duplicated
XA4301 warnings for libbarhopper_v3.so (one pair per ABI being packaged)
Did you find any workaround?
The warning is cosmetic — packaging keeps the first copy and drops the duplicate, so the APK is correct. <NoWarn>$(NoWarn);XA4301</NoWarn> silences it.
Relevant log output
Restore complete (0.6s)
MyApp net9.0-android36.0 succeeded with 2 warning(s) (57.7s) → src/bin/Debug/net9.0-android36.0/MyApp.dll
obj/Debug/net9.0-android36.0/lp/260/jl/jni/arm64-v8a/libbarhopper_v3.so : warning XA4301: APK already contains the item lib/arm64-v8a/libbarhopper_v3.so; ignoring.
obj/Debug/net9.0-android36.0/lp/260/jl/jni/arm64-v8a/libbarhopper_v3.so : warning XA4301: APK already contains the item lib/arm64-v8a/libbarhopper_v3.so; ignoring.
Android framework version
net9.0-android
Affected platform version
.NET SDK 9.0.316, macOS 15 (Apple Silicon)
Description
Xamarin.Google.MLKit.BarcodeScanningincludes the Google Maven artifactcom.google.mlkit:barcode-scanning:17.3.0twice, which producesXA4301duplicate-native-library warnings in every Android build that references the package (directly or transitively, e.g. viaBarcodeScanning.Native.Maui):The two copies come from the same NuGet package through two different mechanisms:
lib/net9.0-android35.0/barcode-scanning.aar(extracted toobj/.../lp/228in my build).Xamarin.Build.Download:buildTransitive/net9.0-android35.0/Xamarin.Google.MLKit.BarcodeScanning.targetsdeclares aXamarinBuildDownloaditem forhttps://dl.google.com/dl/android/maven2/com/google/mlkit/barcode-scanning/17.3.0/barcode-scanning-17.3.0.aar(extracted toobj/.../lp/260).Mapping evidence from
obj/Debug/net9.0-android36.0/libraryimports.cache:On top of that, the targets file adds the downloaded AAR to the item group twice (identical consecutive lines), which is why the XA4301 warning is emitted twice per ABI:
I verified the same double-inclusion (embedded
lib/**/barcode-scanning.aar+XamarinBuildDownloadof the same artifact, with the doubled item line) is present in the latest release 117.3.0.8, in both thenet9.0-android35.0andnet10.0-android36.0targets, so all currently shipping versions are affected (checked 117.3.0.3 and 117.3.0.8).Expected: the artifact is included once — either embedded in
lib/or fetched viaXamarinBuildDownload, not both — and theXamarinBuildDownloadAndroidAarLibraryitem is not duplicated inside the targets.Related: xamarin/GooglePlayServicesComponents#819 reported the same warnings; it was closed without the source of the duplication being identified.
Steps to Reproduce
dotnet new maui<PackageReference Include="Xamarin.Google.MLKit.BarcodeScanning" Version="117.3.0.8" />(orBarcodeScanning.Native.Maui, which depends on it)dotnet build -f net9.0-androidXA4301warnings forlibbarhopper_v3.so(one pair per ABI being packaged)Did you find any workaround?
The warning is cosmetic — packaging keeps the first copy and drops the duplicate, so the APK is correct.
<NoWarn>$(NoWarn);XA4301</NoWarn>silences it.Relevant log output