Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Transitive native library is embedded in consuming class library AAR and duplicated in APK

オープン
#1,503 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
android, csharp

調査の方向性

最小構成の net10.0-android クラス ライブラリで問題を再現して dotnet pack を実行し、その後、生成された AAR と nuspec を調べます。_GetLibraryImports、_CategorizeAndroidLibraries、_CreateAar、_CreateAarCache の項目フローを確認します。保持された依存関係が、外側の AAR に重複して含まれることなく 1 つのネイティブ ライブラリを提供し、クラス ライブラリの Java コンパイルを壊さなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

Android framework version

net10.0-android

Affected platform version

.NET SDK 10.0.x with the net10.0-android workload; also reproduced with Android workload 37.0.0-preview.6.59

Description

Xamarin.AndroidX.Graphics.Path 1.1.0.1 causes its native libandroidx.graphics.path.so payload to be embedded into every consuming Android class library's generated AAR. When that class library is packed as a NuGet, the NuGet also correctly retains Xamarin.AndroidX.Graphics.Path as a dependency. An application consuming the outer NuGet therefore receives the same native library twice and reports XA4301.

The MSBuild item flow is:

  1. Xamarin.AndroidX.Graphics.Path.targets adds androidx.graphics.graphics-path.aar as AndroidAarLibrary.
  2. _GetLibraryImports extracts its native files as AndroidNativeLibrary.
  3. For a class library, _CategorizeAndroidLibraries copies every AndroidNativeLibrary to EmbeddedNativeLibrary.
  4. _CreateAar passes all EmbeddedNativeLibrary items to CreateAar, embedding them into the outer library's generated AAR.
  5. NuGet packing includes that generated AAR and retains the package dependency, so an application receives both copies.

The two copies are byte-for-byte identical. This is not specific to Compose, but it is exposed by packing Microsoft.AndroidX.Compose, which depends transitively on Xamarin.AndroidX.Graphics.Path through Xamarin.AndroidX.Compose.UI.Graphics.Android.

A minimal reproduction is an Android class library with:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net10.0-android</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Xamarin.AndroidX.Graphics.Path" Version="1.1.0.1" />
  </ItemGroup>
</Project>

Run dotnet pack and inspect the resulting package:

  • The generated class-library AAR contains jni/<abi>/libandroidx.graphics.path.so.
  • The nuspec retains the Xamarin.AndroidX.Graphics.Path dependency.

Consume that package from a net10.0-android application and build an APK. The application sees the native library both through the outer AAR and through Xamarin.AndroidX.Graphics.Path.

Expected behavior: a native asset already supplied by a retained NuGet dependency should not also be embedded in the consuming class library's AAR. This may require package-generation changes, an Android SDK item-metadata mechanism, or limiting runtime AAR inclusion to the final application without breaking class-library Java compilation.

We are working around this in Microsoft.AndroidX.Compose by removing libandroidx.graphics.path.so from EmbeddedNativeLibrary after _CategorizeAndroidLibraries and before _CreateAarCache. The package dependency remains, and the final APK still contains one copy per selected ABI.

Relevant log output
obj/Debug/net10.0-android/lp/203/jl/jni/x86_64/libandroidx.graphics.path.so : warning XA4301: APK already contains the item lib/x86_64/libandroidx.graphics.path.so; ignoring.
obj/Debug/net10.0-android/lp/203/jl/jni/arm64-v8a/libandroidx.graphics.path.so : warning XA4301: APK already contains the item lib/arm64-v8a/libandroidx.graphics.path.so; ignoring.
主要言語
C#
スター
319
フォーク
73
平均マージ
2日 15時間
マージ済み PR(30日)
7

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/android-libraries のほかの issue

dotnet/android-libraries の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。