R8 resource shrinking path never runs aapt2 optimize (resource path shortening / sparse encoding have no effect with R8)

Aperta
#534 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 6 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
android, java

Direzione di ricerca

Leggi rules/android_binary/r8.bzl, quindi confronta process_resource_shrinking_r8 con _process_optimize in rules/android_binary/impl.bzl. Esamina la patch indicata e aggiungi test che coprano il percorso R8 con l’abbreviazione dei percorsi delle risorse o la codifica sparse abilitata. Il lavoro è completato quando tali opzioni hanno effetto sull’APK delle risorse R8 senza modificare il comportamento quando sono disabilitate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
205
Fork
113
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bazelbuild/rules_android

Tutte le issue di bazelbuild/rules_android

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.