Replacing Compat Dx With Reference To Internal Bazel Build's Dx #15213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initial Issue:
Bazel fails to build on build_tools_version 31.
Error: Could not find or load main class com.android.tools.r8.compatdx.CompatDx
ceb498f should have fixed the issue. However, I am not able to compile.
The error I get from --verbose_failures boils down to this line
bazel-out/k8-opt-exec-2B5CBBC6/bin/external/androidsdk/d8_compat_dx --dex '--num-threads=5' '--output=bazel-out/k8-fastbuild/bin/apps/presidio/helix/app-apk/_mobile_install/bin_debug/stub_application/classes.dex' bazel-out/k8-fastbuild/bin/apps/presidio/helix/app-apk/_mobile_install/bin_debug/stub_deploy.jar
When I look into the d8_compat_dx, I only see that a manifest file exists in it where it says it was created by "Target-Label: @androidsdk//:d8_compat_dx" and no other classes. Looking at this line in android_sdk_repository.bzl, it looks like Bazel is still trying to use the d8 packaged in build-tools in the Android SDK rather than trying to create its own.
See #13989 for the original discussion.
Fix:
Make the d8_compat_dx reference the internal Bazel built dx tools.
We tested this by running bazel mobile-install on all our apps.