The latest Android Plugin for Gradle v3.1.0 sets D8 as the default dexer, we should add support to use it in android_sdk.
This isn't in buildtools yet, so we'll have to fetch it in WORKSPACE or vendor it.
Now available in buildtools 28.0.1
I am not working on this currently.
What is the status of this? Dx is no longer supported and bazel is the only one using it by default. I am getting reports from a couple of bazel users that are seeing dx fail on their code and d8 does not fail. Is there anything I can do to help move this forward?
ping - any updates on this?
Any updates on this?
The 1.2 release notes hints that D8 is supported on an experimental basis. This issue is referenced there - it's a bit odd to see no updates here.
Yes, the 1.2 release adds D8 support. Let me know if you see any issues.
Quick note on how to actually use d8 in lieu of dx or DexBuilder.
To use the standalone d8 dexer:
bazel build --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx
To use incremental d8 dexer:
bazel build --define=android_incremental_dexing_tool=d8_dexbuilder --nouse_workers_with_dexbuilder
You can also add the below lines to your .bazelrc and switch to d8 by simply specifying --config=d8 in your build command line.
# Flags for using the D8 dexer.
build:d8 --define=android_incremental_dexing_tool=d8_dexbuilder
build:d8 --define=android_standalone_dexing_tool=d8_compat_dx
build:d8 --nouse_workers_with_dexbuilder
Or, even make it default by adding:
build --config=d8
@gyias the .bazelrc configuration don't exactly match your explicit commands. Shouldn't it be:
build:d8 --nouse_workers_with_dexbuilder --define=android_incremental_dexing_tool=d8_dexbuilder
build:d8 --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx
Otherwise you will apply --nouse_workers_with_dexbuilder to d8_compat_dx which is unintentional? and not apply --nouse_workers_with_dexbuilder which is also unintentional?
In general, I tried the new D8 dexer and I noticed that even though it uses the correct
bazel-out/host/bin/external/bazel_tools/tools/android/d8_dexbuilder
or
bazel-out/host/bin/external/androidsdk/d8_compat_dx
But it still uses the older dexMerger:
bazel-out/host/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/dexer/DexFileMerger
is that expected?
@gyias the
.bazelrcconfiguration don't exactly match your explicit commands. Shouldn't it be:build:d8 --nouse_workers_with_dexbuilder --define=android_incremental_dexing_tool=d8_dexbuilder build:d8 --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dxOtherwise you will apply
--nouse_workers_with_dexbuildertod8_compat_dxwhich is unintentional? and not apply--nouse_workers_with_dexbuilderwhich is also unintentional?
No, the sample config is correct. --nouse_workers_with_dexbuilder has no effect d8_compat_dx as it's specifically the for incremental dexing mode. Basically, the sample config applies all three flags when the user specifies --config=d8, and then the user can switch between d8_compat_dx and d8_dexbuilder using --noincremental_dexing, the default being d8_dexbuilder.
In general, I tried the new D8 dexer and I noticed that even though it uses the correct
bazel-out/host/bin/external/bazel_tools/tools/android/d8_dexbuilder
or
bazel-out/host/bin/external/androidsdk/d8_compat_dxBut it still uses the older dexMerger:
bazel-out/host/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/dexer/DexFileMergeris that expected?
Yes, I'm not sure if there's an existing issue to cover it though. I'll create one if there isn't. Thanks for pointing it out.
Thanks for the quick reply!
Do you mind linking me to the new issue when you create it? I'm trying to workaround some DexFileMerger related issues:
https://github.com/bazelbuild/bazel/issues/9384
https://github.com/bazelbuild/bazel/issues/9383
and so far the only thing that works is not using incremental dexing which impacts performance.
Sure, I couldn't find, and so created one.
Most helpful comment
Quick note on how to actually use d8 in lieu of dx or DexBuilder.
To use the standalone d8 dexer:
bazel build --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx
To use incremental d8 dexer:
bazel build --define=android_incremental_dexing_tool=d8_dexbuilder --nouse_workers_with_dexbuilder
You can also add the below lines to your .bazelrc and switch to d8 by simply specifying --config=d8 in your build command line.
# Flags for using the D8 dexer.
build:d8 --define=android_incremental_dexing_tool=d8_dexbuilder
build:d8 --define=android_standalone_dexing_tool=d8_compat_dx
build:d8 --nouse_workers_with_dexbuilder
Or, even make it default by adding:
build --config=d8