Skip to content

Remove build-time Java resources from APKs - #12792

Merged
simonrozsival merged 3 commits into
mainfrom
simonrozsival-remove-apk-dead-weight
Sep 16, 2026
Merged

simonrozsival merged 3 commits into
mainfrom
simonrozsival-remove-apk-dead-weight

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Java archives can contribute build-time-only resources to APK and AAB outputs, including nested classes.jar files, Kotlin Multiplatform metadata, and embedded shrinker configuration.

This change:

  • adds anchored default AndroidPackagingOptionsExclude items in AutoImport.in.props
  • removes nested JARs, KMP metadata, R.txt, ProGuard/R8 rules, and AAR metadata
  • preserves runtime resources such as META-INF/services and Kotlin builtins
  • extends the existing packaging test to cover both APK and AAB paths
  • updates the affected CoreCLR XForms APK size references

Google Play compatibility

Google Play does not use the excluded proguard.txt or META-INF ProGuard/R8 files. These are consumer keep rules from dependency JARs and AARs, and are consumed during the application's R8 build before classes.dex and the final package are produced. The other excluded files are likewise build-time metadata rather than Play publishing inputs.

The final R8 mapping used by Google Play for crash deobfuscation is a separate artifact. For app bundles, it remains preserved as BUNDLE-METADATA/com.android.tools.build.obfuscation/proguard.map; for APK uploads, it can be uploaded separately to Play Console. Play-specific bundle metadata is not affected by these exclusions.

Tests:

  • ./dotnet-local.sh test bin/TestRelease/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~CheckExcludedFilesAreMissing"
  • PATH="$PWD/bin/Release/tools:$PATH" ./dotnet-local.sh test bin/TestRelease/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~BuildReleaseArm64"

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 15, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

AAB archive paths and include overrides need focused test coverage.

Get a fresh assessment by requesting another Copilot review.

Review tier: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR removes build-time-only Java archive entries from APK/AAB packages while preserving runtime resources and explicit inclusion overrides.

Changes:

  • Filters nested JARs, KMP metadata, resource symbols, shrinker rules, and AAR metadata.
  • Adds focused tests and documentation.
  • Updates CoreCLR APK size baselines.
File Summary
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.ProjectTools/​Resources/​Base/​BuildReleaseArm64XFormsDotNet.CoreCLR.R8.apkdesc Updates APK size baseline.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.ProjectTools/​Resources/​Base/​BuildReleaseArm64XFormsDotNet.CoreCLR.apkdesc Updates APK size baseline.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.ProjectTools/​Resources/​Base/​BuildReleaseArm64SimpleDotNet.CoreCLR.R8.apkdesc Updates APK size baseline.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.ProjectTools/​Resources/​Base/​BuildReleaseArm64SimpleDotNet.CoreCLR.apkdesc Updates APK size baseline.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​CollectJarContentFilesForArchiveTests.cs Tests filtering and explicit inclusion.
src/​Xamarin.Android.Build.Tasks/​Tasks/​CollectJarContentFilesForArchive.cs Implements build-time resource filtering.
Documentation/​docs-mobile/​building-apps/​build-items.md Documents packaging behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Combine the R8 consumer-rule exclusions and cover a version-qualified R8 metadata directory in the packaging regression test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival merged commit 483c835 into main Sep 16, 2026
44 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-remove-apk-dead-weight branch September 16, 2026 22:17
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants