README.md
1# Android support in Bazel
2
3## Disclaimer
4
5NOTE: This branch contains a development preview of the Starlark implementation of Android rules for Bazel. This code is incomplete and may not function as-is.
6
7Bazel 4.0.0 or newer and the following flags are necessary to use these rules:
8```
9--experimental_enable_android_migration_apis
10--experimental_google_legacy_api
11--incompatible_java_common_parameters
12--android_databinding_use_v3_4_args
13--experimental_android_databinding_v2
14```
15
16Also, register the Android toolchains in the `WORKSPACE` file with:
17```
18register_toolchains(
19 "@build_bazel_rules_android//toolchains/android:android_default_toolchain",
20 "@build_bazel_rules_android//toolchains/android_sdk:android_sdk_tools",
21)
22```
23(Assuming that the Android rules repository in the `WORKSPACE` file is named `build_bazel_rules_android`.)
24
25## Overview
26
27This repository contains the Starlark implementation of Android rules in Bazel.
28
29The rules are being incrementally converted from their native implementations
30in the [Bazel source
31tree](https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/android/).
32
33For the list of Android rules, see the Bazel [documentation](https://docs.bazel.build/versions/master/be/android.html).
34
35## Getting Started
36To use the new Bazel Android rules, add the following to your WORKSPACE file:
37
38 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
39 http_archive(
40 name = "build_bazel_rules_android",
41 urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
42 sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
43 strip_prefix = "rules_android-0.1.1",
44 )
45
46Then, in your BUILD files, import and use the rules:
47
48 load("@build_bazel_rules_android//rules:rules.bzl", "android_library")
49 android_library(
50 ...
51 )
52