Support R8 resource shrinking to reduce app size and resolve Play Console warnings
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ả
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:
- Build a Release AAB with PublishAot=true and AndroidLinkTool=r8, without custom resource-shrinking integration.
- Upload the signed AAB to Google Play Console.
- Inspect the bundle’s R8 configuration and optimization recommendations.
- 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.
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/android
-
Area: App+Library Build
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
EditText.getText() isn't boundĐang mởArea: Mono.Android
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
dotnet/android#9192 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
AndroidTypeMapImplementation trimmable removes types that are used in type castsCó thể đã có người làm @simonrozsival đã nhận hôm nay. Đang mởArea: App Runtime bug trimmable-type-map
dotnet/android#13286 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
flaky-ci flaky-tests needs-triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Area: App+Library Build needs-triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 56/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của dotnet/android
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
:watch: Not Triaged advanced-concepts/subsvc dotnet-csharp/svc
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement no-stack-trace
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
greenshot/greenshot#1618 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
microsoft/aspire.dev#1962 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-area-label
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày