bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Support D8

Open jin opened this issue 8 years ago • 13 comments

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.

jin avatar May 03 '18 04:05 jin

This isn't in buildtools yet, so we'll have to fetch it in WORKSPACE or vendor it.

jin avatar May 04 '18 21:05 jin

Now available in buildtools 28.0.1

jin avatar Jul 09 '18 23:07 jin

I am not working on this currently.

jin avatar Jan 18 '19 00:01 jin

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?

madsager avatar Aug 14 '19 07:08 madsager

ping - any updates on this?

nkoroste avatar Sep 13 '19 21:09 nkoroste

Any updates on this?

anuchandy avatar Sep 30 '19 04:09 anuchandy

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.

rzsombor avatar Nov 13 '19 10:11 rzsombor

Yes, the 1.2 release adds D8 support. Let me know if you see any issues.

gyias avatar Nov 14 '19 18:11 gyias

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 avatar Nov 14 '19 19:11 gyias

@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?

nkoroste avatar Nov 21 '19 20:11 nkoroste

@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?

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_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?

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.

gyias avatar Nov 21 '19 21:11 gyias

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.

nkoroste avatar Nov 21 '19 22:11 nkoroste

Sure, I couldn't find, and so created one. #10287

gyias avatar Nov 21 '19 22:11 gyias