Core library desugaring: the desugared library is appended to the APK unshrunk
Les mainteneurs répondent en général sous 6 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Calme
- Domaine
- build-system, mobile
Piste de recherche
Commencez par examiner le chemin R8 actuel et le correctif lié qui reproduit le pipeline AGP R8 -> TraceReferences -> L8. Vérifiez que TraceReferences reçoit le même ensemble de bibliothèques que R8, que L8 utilise le SDK minimal effectif et que la bibliothèque desugarée réduite est ajoutée ; ajoutez des tests couvrant le comportement par défaut ou celui du flag sélectionné.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
When core library desugaring is enabled, the R8 path appends the prebuilt java8_legacy_dex from the toolchain to the final dexes wholesale. There is no shrinking step at all, so every APK bundles the entire j$.* runtime regardless of how much of it the app actually uses.
AGP instead runs an R8 -> TraceReferences -> L8 pipeline: trace which j$.* APIs the optimized app actually reaches, shrink the desugared library down to those with L8, and append the result. So compared to a Gradle build of the same app, the Bazel APK carries a lot of dead j$.* code.
Numbers from our app (nio desugar config): total dex size went from ~16 MiB to ~14 MiB with shrinking, i.e. roughly 2 MiB of unused j$.* code was being shipped.
We're running a patch that reproduces the AGP pipeline: https://github.com/Dolfik1/rules_android/commit/031d22ff19929170e8a8e15bae3e077c96a431dc
Notes on the patch:
- TraceReferences is used to produce the L8 keep rules because R8 9.x removed
--desugared-lib-pg-conf-output, so R8 can no longer emit them itself. TraceReferences is the R8-sanctioned replacement and what AGP uses. - TraceReferences needs
--libto be the same library set R8 saw (android.jar plus the app's neverlink/compile-only jars), not android.jar alone. If a j$.* member is only reachable through a dependency class missing from --lib, resolution fails and that keep rule is silently dropped, which would surface as runtime NoClassDefFoundError instead of a build error. - L8 runs with
-dontobfuscate. AGP also obfuscates the desugared library and surfaces a mapping for retrace; the current rules_android path appends a D8-built (unminified) dex, so keeping names readable matches existing behavior. Matching AGP's obfuscation + mapping would be a follow-up. --min-apiis set to the binary's effective min SDK instead of whatever the prebuilt java8_legacy_dex was baked with.- New toolchain attrs: l8, tracereferences, desugar_jdk_libs_all, desugared_jdk_libs_jar.
Happy to turn this into a PR with tests if you'd take it. Main design question is whether you'd want the shrinking pipeline gated behind a flag or as the new default for the R8 path.
- Langage dominant
- Java
- Étoiles
- 205
- Forks
- 113
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de bazelbuild/rules_android
-
build_java8_legacy_dex.sh does not set JAVA_RUNFILES for the d8/r8 launchersPeut-être pris @TrapsterDK l’a pris il y a 17 jours. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
bazelbuild/rules_android#599 ·
Les mainteneurs répondent en général sous 6 jours
-
`Desugar` actions don't run on multiplex workersPeut-être pris @lukaciko l’a pris il y a 46 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
bazelbuild/rules_android#539 · 2 commentaires ·
Les mainteneurs répondent en général sous 6 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
bazelbuild/rules_android#535 · 2 réactions ·
Les mainteneurs répondent en général sous 6 jours
-
desugar_globals output is not reproducible (zip entry order varies)Peut-être pris @TrapsterDK l’a pris il y a 6 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 30/100
bazelbuild/rules_android#610 ·
Les mainteneurs répondent en général sous 6 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 42/100
bazelbuild/rules_android#602 ·
Les mainteneurs répondent en général sous 6 jours
Toutes les issues de bazelbuild/rules_android
Issues similaires
-
[P2] 生产环境下启动门闩的失败明细不进容器标准输出Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Lincoln-cn/JAiRouter#1473 ·
Les mainteneurs répondent en général sous 1 jour
-
Link not working in the feedback concerning String.format() in exercise 'Tim from Marketing'Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
exercism/java-analyzer#379 ·
-
area: ui bug priority: low
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
tetsuji16/microProject#1893 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
liberation-data/fornax4j#325 ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: FE and Kinesis extraction pipes render flow starting at the centre and scroll the source arm backwardsPeut-être pris @chonkzillaofficial l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
BCCE-team/BuildCraft#85 ·