rules_android icon indicating copy to clipboard operation
rules_android copied to clipboard

[bazel.build] Problem with /start/android-app

Open hbf17517 opened this issue 11 months ago • 5 comments

Page link:

https://bazel.build/start/android-app

Problem description (include actual vs expected text, if applicable):

The page says: Bazel supports building Android apps using the Android rules.

But the link https://bazel.build/reference/be/android is broken.

Where do you see this issue? (include link to specific section of the page, if applicable)

https://bazel.build/start/android-app

Any other information you'd like to share?

No response

hbf17517 avatar Mar 11 '25 01:03 hbf17517

Hi,

I collapsed the other issues you opned (#25526, bazelbuild/bazel#25525) into this one since they're all related.

The various examples and tutorials for Bazel Android apps have all become outdated as of the Bazel 8 release, which removed support for the natively-defined Android rules. The replacements are at github.com/bazelbuild/rules_android and github.com/bazelbuild/rules_android_ndk. We (the Bazel Android team) do we have a roadmap item to fix the docs and examples, but it will take some time. Meanwhile, users can look at those repositories' example projects to get started.

I'm also going to transfer this issue to the rules_android github page, since most Bazel Android development work happens there.

ted-xie avatar Mar 11 '25 19:03 ted-xie

It would be helpful to have a note in the tutorials that they are outdated, even if it's too much work to update them right now. I was also unable to follow the example for the basicapp in rules_android: there is a "local_path_override" that points to "../..". That obviously doesn't work for a project not in the rules_android repository. A comment in the file to say what path that should be would be helpful.

Moreover, the WORKSPACE file in the example appears to be an old-style file, in that it has functions not available in Bazel 8. Is that intended?

janakdr avatar Mar 19 '25 04:03 janakdr

Hi Janak,

The basicapp itself is modern (it support both bzlmod and WORKSPACE) and regularly updated. Moreover, we do have integration instructions in release notes for this ruleset:

https://github.com/bazelbuild/rules_android/releases/tag/v0.6.3

I think the bzlmod section of the release notes could be improved a bit more, but the WORKSPACE portion is fully functional.

ted-xie avatar Mar 19 '25 14:03 ted-xie

Hi Ted, thanks for the quick reply. I'm still a bit confused. If someone wants to clone basicapp and build it with MODULE.bazel, I don't think the instructions in the release notes are sufficient, since they just say to add bazel_dep(name = "rules_android", version = "0.6.3") to the file. But the issue of the local_path_override doesn't seem to be resolved by that?

janakdr avatar Mar 19 '25 15:03 janakdr

I'm working on a change internally that should at least address the most glaring issues, including a proper treatment of MODULE.bazel setup.

RE local_path_override: This is a necessary evil so that the example app can be used for presubmit integration testing. I suppose we could add some comments in the MODULE file like so:

bazel_dep(name = "rules_android", version = "0.6.3")

# Local override to enable this app to be used for rules_android presubmit integration testing.
# If you're basing your app's MODULE file on this example, you do *not* need the following override.
local_path_override(...)

ted-xie avatar Mar 24 '25 20:03 ted-xie

The Bazel Android basic tutorial page should be up to date now.

ted-xie avatar Aug 21 '25 19:08 ted-xie