https://android-developers.googleblog.com/2018/04/android-studio-switching-to-d8-dexer.html It's now the default in Android Studio. Benefits: * Faster than DX * Produces smaller dex files It was meant to be a drop in replacement for DX so we shouldn't have to do much extra work to get this working. It also supports desugar, so we can remove the extra bytecode rewriting logic we have to do this - specifically: * https://cs.chromium.org/chromium/src/third_party/bazel/desugar/?q=desugar&sq=package:chromium&dr * https://cs.chromium.org/chromium/src/build/android/gyp/desugar.py * https://cs.chromium.org/chromium/src/build/config/android/internal_rules.gni?type=cs&q=desugar+file:.gn&sq=package:chromium&g=0&l=1314 Steps to do this: 1. Check in a prebuilt at //third_party/d8 * Build d8.jar via the steps mentioned at https://r8.googlesource.com/r8 * Follow https://chromium.googlesource.com/chromium/src.git/+/master/docs/adding_to_third_party.md for checking in (including the section about large files) 2. An a gn arg for enabling d8, use_d8 * Modify this template to support d8: https://cs.chromium.org/chromium/src/build/config/android/internal_rules.gni?rcl=cc7faaf76c126b4a2900d7b56bda3d06d5cc50ed&l=995 3. Default use_d8 = true 4. Once we've verified that there are no issues, tear out everything related to DX
https://android-developers.googleblog.com/2018/04/android-studio-switching-to-d8-dexer.html It's now the default in Android Studio. Benefits: * Faster than DX * Produces smaller dex files It was meant to be a drop in replacement for DX so we shouldn't have to do much extra work to get this working. It also supports desugar, so we can remove the extra bytecode rewriting logic we have to do this - specifically: * https://cs.chromium.org/chromium/src/third_party/bazel/desugar/?q=desugar&sq=package:chromium&dr * https://cs.chromium.org/chromium/src/build/android/gyp/desugar.py * https://cs.chromium.org/chromium/src/build/config/android/internal_rules.gni?type=cs&q=desugar+file:.gn&sq=package:chromium&g=0&l=1314 Steps to do this: 1. Check in a prebuilt at //third_party/d8 * Build d8.jar via the steps mentioned at https://r8.googlesource.com/r8 * Follow https://chromium.googlesource.com/chromium/src.git/+/master/docs/adding_to_third_party.md for checking in (including the section about large files) 2. An a gn arg for enabling d8, use_d8 * Modify this template to support d8: https://cs.chromium.org/chromium/src/build/config/android/internal_rules.gni?rcl=cc7faaf76c126b4a2900d7b56bda3d06d5cc50ed&l=995 * Modify dex.py to work with d8: https://cs.chromium.org/chromium/src/build/android/gyp/dex.py?q=dex.py&sq=package:chromium&dr 3. Default use_d8 = true 4. Once we've verified that there are no issues, tear out everything related to DX
agrieve@ mentioned offline that we'll also want to check if our internal proguard works well on d8 desugar'ed dex files and if not use the --no-desugaring flag in d8.
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/95b7b7dd3773dd1b454f39b33f83743b076eb266 commit 95b7b7dd3773dd1b454f39b33f83743b076eb266 Author: Tiger Oakes <tigero@google.com> Date: Mon May 28 15:43:49 2018 Added r8 package with compatdx file. This will be used to replace DX with D8. D8 is part of the R8 repo and offers a compatdx jar that takes the same arguments as DX. Bug: 842681 Change-Id: I2220cbbdc33dac3729e63f4f47467f09254314d6 Reviewed-on: https://chromium-review.googlesource.com/1060169 Reviewed-by: Grace Kloba <klobag@chromium.org> Reviewed-by: agrieve <agrieve@chromium.org> Reviewed-by: Eric Stevenson <estevenson@chromium.org> Commit-Queue: Tiger Oakes <tigero@google.com> Cr-Commit-Position: refs/heads/master@{#562268} [modify] https://crrev.com/95b7b7dd3773dd1b454f39b33f83743b076eb266/DEPS [modify] https://crrev.com/95b7b7dd3773dd1b454f39b33f83743b076eb266/third_party/.gitignore [add] https://crrev.com/95b7b7dd3773dd1b454f39b33f83743b076eb266/third_party/r8/LICENSE [add] https://crrev.com/95b7b7dd3773dd1b454f39b33f83743b076eb266/third_party/r8/OWNERS [add] https://crrev.com/95b7b7dd3773dd1b454f39b33f83743b076eb266/third_party/r8/README.chromium [add] https://crrev.com/95b7b7dd3773dd1b454f39b33f83743b076eb266/third_party/r8/cipd.yaml
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/2e3db78141260081f2da2a849659675666613e98 commit 2e3db78141260081f2da2a849659675666613e98 Author: Tiger Oakes <tigero@google.com> Date: Thu Jun 07 17:57:22 2018 Added enable_d8 to uses D8 instead of DX D8 is the new default dexer in Android Studio. We're replacing DX with D8. This improves the APK size by removing 30 KB. Bug: 842681 Change-Id: Ic0d310f615d6aad44a55a2ab5f56ef40288df53f Reviewed-on: https://chromium-review.googlesource.com/1079373 Commit-Queue: Tiger Oakes <tigero@google.com> Reviewed-by: Eric Stevenson <estevenson@chromium.org> Reviewed-by: agrieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/master@{#565336} [modify] https://crrev.com/2e3db78141260081f2da2a849659675666613e98/DEPS [modify] https://crrev.com/2e3db78141260081f2da2a849659675666613e98/build/android/gyp/dex.py [modify] https://crrev.com/2e3db78141260081f2da2a849659675666613e98/build/config/android/internal_rules.gni [modify] https://crrev.com/2e3db78141260081f2da2a849659675666613e98/third_party/r8/README.chromium [modify] https://crrev.com/2e3db78141260081f2da2a849659675666613e98/third_party/r8/cipd.yaml
Comment 1 by estevenson@chromium.org
, May 14 2018