rules_android
rules_android copied to clipboard
bzlmod support
Currently fails with this:
no such target '//external:databinding_annotation_processor': target 'databinding_annotation_processor' not declared in package 'external' defined by <workspace path>/WORKSPACE (Tip: use `query "//external:*"` to see all the targets in that package) and referenced by '@bazel_tools//tools/android:databinding_annotation_processor'
@ahumesky @meisterT
I think that's referenced here: https://github.com/bazelbuild/bazel/blob/d0e29582a2e788e8acdaf53fe30ab7f7dc592df3/tools/android/BUILD.tools#L448
For the starlark rules at least, I think we can point them here instead: https://github.com/bazelbuild/rules_android/blob/a6b9b7921f220f437858b8e19cdd0524923f4f16/tools/android/BUILD#L35
Hm, we appear to already be doing that: https://github.com/bazelbuild/rules_android/blob/a6b9b7921f220f437858b8e19cdd0524923f4f16/toolchains/android/toolchain.bzl#L107
So probably coming from the parts of android_binary that are still in native: https://github.com/bazelbuild/rules_android/blob/a6b9b7921f220f437858b8e19cdd0524923f4f16/rules/android_binary.bzl#L43
But I think we could replace this:
https://github.com/bazelbuild/bazel/blob/d0e29582a2e788e8acdaf53fe30ab7f7dc592df3/tools/android/BUILD.tools#L446-L449
with this: https://github.com/bazelbuild/rules_android/blob/a6b9b7921f220f437858b8e19cdd0524923f4f16/tools/android/BUILD#L34-L42
and change the name to match the existing alias, it should "just work"
Hi folks, quick question - i'm new to bzlmod and trying to setup my android project using bzlmod.
I'm not sure if there's an equivalent to WORKSPACE's android_sdk_repository in bzlmod? When i try to build android_library targets with my MODULE.bazel depending on rules_android module i run into the following error:
While resolving toolchains for target //:sample: No matching toolchains found for types @bazel_tools//tools/android:sdk_toolchain_type.
Wondering if this is related to this issue. i.e. it's not possible yet to setup android projects using bzlmod?
@telescopic Bzlmod works now but you will need to be using the latest Bazel rolling release until the actual fix get backported into the 6.x release track.
@Bencodes thanks for your reply - is there any documentation surrounding the same?
@telescopic not much documentation right now.
Bzlmod doesn't actually seem to be fully working if you are using rules_android at HEAD. If you are still using the native rules it's possible to get everything working. Example: https://github.com/robolectric/robolectric-bazel/tree/master/examples/simple
bzlmod support doesn't seem to be working at all: I created a minimal example showing that following the basic instructions on the main README here leads to the repo not being found.
EDIT Huh apparently I had a problem with my bazelrc (failed to include line-continuations), adding those in so the flags were all present I ended up with a different error:
ERROR: no such package '@@android_gmaven_r8//jar': The repository '@@android_gmaven_r8' could not be resolved: Repository '@@android_gmaven_r8' is not defined
ERROR: D:/_bazel_out/lbijidmj/external/androidsdk/BUILD.bazel:31:25: no such package '@@android_gmaven_r8//jar': The repository '@@android_gmaven_r8' could not be resolved: Repository '@@android_gmaven_r8' is not defined and referenced by
'@@androidsdk//:d8_jar_import'
Hi @bdleitner,
The README is sadly not entirely up to date, especially for bzlmod integration. We will address documentation shortcomings later this year as part of the overall rules maturation process. I have a change in progress that adds the following lines to MODULE.bazel for the example app that should address the issue you're seeing.
remote_android_extensions = use_extension("@bazel_tools//tools/android:android_extensions.bzl", "remote_android_tools_extensions")
use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools")
bzlmod and BCR is now supported with 0.5.0 release