@@androidsdk//:dx_jar_import' is misplaced
Description of the bug:
/bazel_tools/tools/android/BUILD:248:12: in runtime_deps attribute of java_binary rule @@bazel_tools//tools/android:dexer: alias '//external:android/dx_jar_import' referring to filegroup rule '@@androidsdk//:dx_jar_import' is misplaced here (expected cc_binary, cc_library, genrule, genproto, java_import, java_library, java_proto_library, java_lite_proto_library, proto_library, sh_binary or sh_library) and '@@androidsdk//:dx_jar_import' does not have mandatory providers: 'CcInfo' or 'JavaInfo'. Since this rule was created by the macro 'java_binary', the error might have been caused by the macro implementation
Which category does this issue belong to?
No response
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
No response
Which operating system are you running Bazel on?
Windows 11, And Ubuntu 22.0
What is the output of bazel info release?
release 7.0.2
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 HEAD ?
No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
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
@kiritgothi Could you please provide complete steps to reproduce this issue? Thanks
I am building "android-testdpc" project with "bazel build testdpc" command. Unfortunately I got error in both windows and ubuntu. This error comes from cache file of bazel which build.
ERROR: %user%/jjzqyj3b/external/bazel_tools/tools/android/BUILD:248:12: in runtime_deps attribute of java_binary rule @@bazel_tools//tools/android:dexer: alias '//external:android/dx_jar_import' referring to filegroup rule '@@androidsdk//:dx_jar_import' is misplaced here (expected cc_binary, cc_library, genrule, genproto, java_import, java_library, java_proto_library, java_lite_proto_library, proto_library, sh_binary or sh_library) and '@@androidsdk//:dx_jar_import' does not have mandatory providers: 'CcInfo' or 'JavaInfo'. Since this rule was created by the macro 'java_binary', the error might have been caused by the macro implementation ERROR: %user%/jjzqyj3b/external/bazel_tools/tools/android/BUILD:248:12: Analysis of target '@@bazel_tools//tools/android:dexer' failed ERROR: Analysis of target '//:testdpc' failed; build aborted: Analysis failed INFO: Elapsed time: 15.281s, Critical Path: 0.07s INFO: 1 process: 1 internal. ERROR: Build did NOT complete successfully
Are you using the rules from github.com/bazelbuild/rules-android or the built-in ("native") android rules? Do you see the same failure if you pass --enable_bzlmod=false?
Answering my own question, looking at https://github.com/googlesamples/android-testdpc/blob/master/BUILD, these are the native rules.
I wasn't able to reproduce this error, here or during debugging in https://github.com/bazelbuild/bazel/issues/21632 with a fork of android-testdpc (at the time it had only 1 commit difference that shouldn't be relevant here) -- are there any other details you can give to help reproduce the error?
I did some tests as well on two different machines (Mac OS and Debian) and I cannot reproduce this with Bazel v7.1.0.
I think this may be happening with bzlmod projects when the $ANDROID_HOME environment variable is not set
I faced that issue but resolved with
I think this may be happening with bzlmod projects when the $ANDROID_HOME environment variable is not set
above gottagofaster236's comment.
export ANDROID_HOME={YOUR_HOME_DIR}/Android/Sdk
I'm experiencing the same issue for the first time while building this new Bazel build for testDPC 9.0.6.
I've tried export ANDROID_HOME={YOUR_HOME_DIR}/Android/Sdk and type env command on the terminal if the environment variable is set, but the issue still persist.
I'm using Bazel v7.1.1 and Debian OS. I will get back if ever I find a fix for this.
I'm experiencing the same issue for the first time while building this new Bazel build for testDPC 9.0.6. I've tried
export ANDROID_HOME={YOUR_HOME_DIR}/Android/Sdkand typeenvcommand on the terminal if the environment variable is set, but the issue still persist.I'm using Bazel v7.1.1 and Debian OS. I will get back if ever I find a fix for this.
I tried this one again and it works. Make sure that you run export ANDROID_HOME={YOUR_HOME_DIR}/Android/Sdk inside android-testdpc folder, after that run bazel build testdpc
android_sdk_repository still references dx: https://github.com/bazelbuild/rules_android/blob/8ab67ca94822a78ad9acca87734beab3d5f69411/rules/android_sdk_repository/helper.bzl#L398-L411 that should just be removed