R8 resource shrinking path never runs aapt2 optimize (resource path shortening / sparse encoding have no effect with R8)
维护者通常 6 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
调研方向
阅读 rules/android_binary/r8.bzl,然后比较 rules/android_binary/impl.bzl 中的 process_resource_shrinking_r8 和 _process_optimize。审查所引用的补丁,并添加涵盖启用资源路径缩短或稀疏编码时 R8 路径的测试。完成的标准是这些选项会在 R8 资源 APK 上生效,同时在禁用这些选项时行为不发生变化。
由索引模型根据 Issue 内容生成。
描述
The legacy ProGuard pipeline runs aapt2 optimize after resource shrinking (see _process_optimize in rules/android_binary/impl.bzl). The R8 resource shrinking path (process_resource_shrinking_r8 in rules/android_binary/r8.bzl) stops after producing the shrunk resource APK and never invokes optimize.
As a result, //rules/flags:experimental_android_resource_path_shortening and the enable_sparse_encoding attribute silently do nothing when R8 is used.
There's no error or warning — they're just ignored, which is easy to miss when migrating and comparing APK sizes against a Gradle build (AGP applies these optimizations as part of its R8 pipeline). We confirmed on our app that with the flag set, resource paths in the APK stay unshortened on the R8 path.
We're running a patch that wires _resources.optimize into the R8 path after the shrinking step, after which path shortening works as expected: https://github.com/Dolfik1/rules_android/commit/fa29d470bbe9f609c83a0993259a29a8e6994371
Notes:
- _resources.optimize already gates itself on the path-shortening flag, compilation mode and ACLs, so the added call is a no-op unless those are enabled — behavior for anyone not using these features is unchanged.
- Resource name obfuscation is left disabled: it needs the resource optimization config that the R8 resource shrinker doesn't produce (resource_optimization_config = None). Could be a follow-up.
Happy to send a PR with tests if this looks right.
- 主要语言
- Java
- 星标
- 205
- 派生
- 113
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bazelbuild/rules_android 的其他 Issue
-
build_java8_legacy_dex.sh does not set JAVA_RUNFILES for the d8/r8 launchers可能已有人在做 @TrapsterDK 于 17 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 72/100
bazelbuild/rules_android#599 ·
维护者通常 6 天内回复
-
`Desugar` actions don't run on multiplex workers可能已有人在做 @lukaciko 于 46 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
bazelbuild/rules_android#539 · 2 条评论 ·
维护者通常 6 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
bazelbuild/rules_android#535 · 2 个 reaction ·
维护者通常 6 天内回复
-
desugar_globals output is not reproducible (zip entry order varies)可能已有人在做 @TrapsterDK 于 6 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 30/100
bazelbuild/rules_android#610 ·
维护者通常 6 天内回复
-
难度 2/5 1-3 小时 新手友好度 42/100
bazelbuild/rules_android#602 ·
维护者通常 6 天内回复
查看 bazelbuild/rules_android 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
Lincoln-cn/JAiRouter#1473 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
exercism/java-analyzer#379 ·
-
area: ui bug priority: low
难度 2/5 1-3 小时 新手友好度 66/100
tetsuji16/microProject#1893 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
liberation-data/fornax4j#325 ·
维护者通常 1 天内回复
-
[Bug]: FE and Kinesis extraction pipes render flow starting at the centre and scroll the source arm backwards可能已有人在做 @chonkzillaofficial 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
BCCE-team/BuildCraft#85 ·