Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Support R8 resource shrinking to reduce app size and resolve Play Console warnings

Đang mở
#13,252 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, csharp
Lĩnh vực
build-system, mobile

Hướng nghiên cứu

Start by reviewing the attached workaround and its setup instructions, then trace the Android SDK’s R8 invocation and AAB packaging path. The issue asks for a supported MSBuild property that preserves managed resources and R8 metadata; done means resource shrinking is enabled in Play Console, protected resource names and IDs remain unchanged, and bundle validation passes.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Area: App+Library Build enhancement
Android framework version

net11.0-android (Preview)

Affected platform version

.NET SDK 11.0.100-rc.2.26504.105 Microsoft.Android.Sdk.Windows 37.2.0-rc.2.84 Bundled R8 9.4.24

Description

Following up on #5203, I’d like to request supported R8 resource shrinking in .NET for Android.

Even with R8 full mode and class repackaging enabled, Google Play Console warns that resource shrinking is disabled.

I tested a local MSBuild workaround across several NativeAOT projects and confirmed two benefits:

  • Modest size reductions: approximately 75–182 KB per signed AAB and 114–214 KB in device-specific installed APK files.
  • Play Console recognizes resource shrinking as enabled, resolving the warning about disabled resource shrinking.

The comparisons used matched builds with shrinking disabled/enabled. Native libraries, assets and manifests were identical within each pair. Installed APK measurements used an arm64 device profile and exclude app data, caches and Android-generated runtime files.

Could resource shrinking be exposed through a supported MSBuild property, with managed resource retention, packaging and R8 metadata handled by the SDK?

Steps to Reproduce

Observed with existing .NET 11 Android applications using NativeAOT:

  1. Build a Release AAB with PublishAot=true and AndroidLinkTool=r8, without custom resource-shrinking integration.
  2. Upload the signed AAB to Google Play Console.
  3. Inspect the bundle’s R8 configuration and optimization recommendations.
  4. Resource shrinking is shown as disabled, and Play Console recommends enabling it.

After adding custom resource-shrinking integration and uploading a new build, Play Console shows resource shrinking as enabled.

Did you find any workaround?

Yes. I implemented a local MSBuild integration using the bundled R8 resource shrinker.

It retains the SDK’s Java inputs, ProGuard rules, mapping and compiler-generated r8.json metadata. Since R8 cannot see managed resource access, it scans NativeAOT input assemblies and generates Java resource roots, conservatively preserving application resources and dynamic string lookups.

The shrunk resource archive is passed into normal AAB packaging and signing. After shrinking, AAPT verifies that protected resource names and IDs remain unchanged. Release builds and bundle validation passed for the tested projects.

Optimized resource shrinking remains disabled: R8 warned about the SDK-generated final Java R fields, so I have not validated that mode. Play Console now checks standard resource shrinking, while optimized resource shrinking remains unchecked.

The workaround depends on SDK implementation details, so built-in support would be preferable.

Attached is an anonymized, source-only version of the workaround, including setup instructions and required NativeAOT compatibility rules, validated with a separate minimal NativeAOT application.

dotnet-android-13252-workaround.zip

Ngôn ngữ chính
C#
Star
2.1k
Fork
579
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
236

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/android

Tất cả issue của dotnet/android

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.