question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bazel tries to use dx instead of d8 if using default dex_shards with Android Build Tools >=31

See original GitHub issue

Description of the bug:

Android build tools >=31 removed dx in favor of d8. However, when building an android_binary, Bazel still attempts to use dx if dex_shards is 1 (as the unset default or explicitly set to 1). Setting a non-standard dex_shards makes this go away, but Bazel shouldn’t be trying to use dx regardless.

This behavior persists even if using flags to explicitly use d8:

build --define=android_dexmerger_tool=d8_dexmerger
build --define=android_incremental_dexing_tool=d8_dexbuilder
build --define=android_standalone_dexing_tool=d8_compat_dx

What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Example project at https://github.com/pswaminathan/barest-kotlin/pull/2.

58e6843 updates the build tools to a version without dx. This commit does not build. The error message I receive is:

ERROR: /private/var/tmp/_bazel_p/afc4c6dd0737eebec931aeb282f26bc9/external/androidsdk/BUILD.bazel:13:25: Extracting interface @androidsdk//:dx_jar_import [for tool] failed: missing input file '@androidsdk//:build-tools/31.0.0/lib/dx.jar'

56e4806 fixes it simply by adding dex_shards = 2.

Which operating system are you running Bazel on?

macOS Monterey (12.5.1)

What is the output of bazel info release?

release 6.0.0-pre.20220818.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pswaminathancommented, Sep 29, 2022

Hmm, interesting, I’m not able to reproduce it now either. Maybe something was cached? Interestingly, one of our other team members was experiencing this as well. I’ll ask him to try reproducing again.

0reactions
ahumeskycommented, Oct 25, 2022

let us know if this is still an issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failing to run d8_dexbuilder with buildtools 31 · Issue #13989
bzl, it looks like Bazel is still trying to use the d8 packaged in build-tools in the Android SDK rather than trying to...
Read more >
Gradle build fails with build tools 31.0.0 - Unity Forum
The solution is that these files are named d8 in the file location so changing their name to dx will solve the error....
Read more >
Android Studio error "Installed Build Tools revision 31.0.0 is ...
The main problem is the two files missing in SDK build tool 31 that are: dx. ... It looks like DX is removed...
Read more >
SDK Build Tools release notes - Android Developers
If you're using Android plugin for Gradle 3.0.0 or higher, your project automatically uses a default version of the build tools that the...
Read more >
Installed Build Tools revision 31.0.0-rc5 is corrupted
Remove and install again using the SDK Manager. I have removed and installed it a few times already without any luck. When I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found