Snap for 7961093 from 7f7740c9ea674bf465c2afe0496065f7a6a0449e to tm-release

Change-Id: If6faf2ea3691294385d3a5c3aa98faa1611e480e
diff --git a/README.md b/README.md
index 6cba04f..1d3ffbf 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 
 NOTE: 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.
 
-Bazel 4.0.0 or newer and the following flags are necessary to use these rules:
+A version of Bazel built at or near head and the following flags are necessary to use these rules:
 ```
 --experimental_enable_android_migration_apis
 --experimental_google_legacy_api
@@ -13,15 +13,6 @@
 --experimental_android_databinding_v2
 ```
 
-Also, register the Android toolchains in the `WORKSPACE` file with:
-```
-register_toolchains(
-  "@build_bazel_rules_android//toolchains/android:android_default_toolchain",
-  "@build_bazel_rules_android//toolchains/android_sdk:android_sdk_tools",
-)
-```
-(Assuming that the Android rules repository in the `WORKSPACE` file is named `build_bazel_rules_android`.)
-
 ## Overview
 
 This repository contains the Starlark implementation of Android rules in Bazel.
@@ -38,10 +29,17 @@
     load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
     http_archive(
         name = "build_bazel_rules_android",
-        urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
-        sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
-        strip_prefix = "rules_android-0.1.1",
+        urls = ["https://github.com/bazelbuild/rules_android/archive/refs/heads/pre-alpha.zip"],
+        strip_prefix = "rules_android-pre-alpha",
     )
+    load("@build_bazel_rules_android//:defs.bzl", "rules_android_workspace")
+    rules_android_workspace()
+    
+    register_toolchains(
+      "@build_bazel_rules_android//toolchains/android:android_default_toolchain",
+      "@build_bazel_rules_android//toolchains/android_sdk:android_sdk_tools",
+    )
+
 
 Then, in your BUILD files, import and use the rules:
 
diff --git a/defs.bzl b/defs.bzl
index 4ac34cc..4d08708 100644
--- a/defs.bzl
+++ b/defs.bzl
@@ -16,21 +16,16 @@
 
 load("@rules_jvm_external//:defs.bzl", "maven_install")
 
-def rules_android_workspace(name):
-  """ Sets up workspace dependencies for rules_android."""
+def rules_android_workspace():
+    """ Sets up workspace dependencies for rules_android."""
 
-  native.register_toolchains(
-      "@rules_android//toolchains/android:android_default_toolchain",
-      "@rules_android//toolchains/android_sdk:android_sdk_tools",
-  )
-
-  maven_install(
-      name = "rules_android_maven",
-      artifacts = [
-        "com.android.tools.build:bundletool:1.6.1",
-      ],
-      repositories = [
-          "https://maven.google.com",
-          "https://repo1.maven.org/maven2",
-      ],
-  )
+    maven_install(
+        name = "rules_android_maven",
+        artifacts = [
+            "com.android.tools.build:bundletool:1.6.1",
+        ],
+        repositories = [
+            "https://maven.google.com",
+            "https://repo1.maven.org/maven2",
+        ],
+    )
diff --git a/rules/BUILD b/rules/BUILD
index d4c8d88..ac89362 100644
--- a/rules/BUILD
+++ b/rules/BUILD
@@ -8,5 +8,5 @@
 alias(
     name = "ResourceProcessorBusyBox",
     actual = "@bazel_tools//tools/android:busybox",
-    visibility =  ["//visibility:public"],
+    visibility = ["//visibility:public"],
 )
diff --git a/rules/aar_import/impl.bzl b/rules/aar_import/impl.bzl
index cec5a84..280060e 100644
--- a/rules/aar_import/impl.bzl
+++ b/rules/aar_import/impl.bzl
@@ -248,7 +248,10 @@
     args = ctx.actions.args()
     args.add_all(jars_to_check, before_each = "--input")
     args.add_all(declared_deps, before_each = "--directdep")
-    args.add_all(transitive_deps, before_each = "--classpath_entry")
+    args.add_all(
+        depset(order = "preorder", transitive = [declared_deps, transitive_deps]),
+        before_each = "--classpath_entry",
+    )
     args.add_all(bootclasspath, before_each = "--bootclasspath_entry")
     args.add("--checking_mode=error")
     args.add("--jdeps_output", jdeps_output)
diff --git a/rules/acls.bzl b/rules/acls.bzl
index ea5032d..ffa1377 100644
--- a/rules/acls.bzl
+++ b/rules/acls.bzl
@@ -15,7 +15,7 @@
 """Access Control Lists.
 
 To create a new list:
-  1. Create new .bzl file in this directory with a list of targets.
+  1. Create new .bzl file in the acls directory with a list of targets.
   2. Create matching method in this file.
   3. Add matching method to struct.
 
@@ -42,13 +42,14 @@
 load("@rules_android//rules/acls:android_feature_splits_dogfood.bzl", "ANDROID_FEATURE_SPLITS_DOGFOOD")
 load("@rules_android//rules/acls:android_library_implicit_exports.bzl", "ANDROID_LIBRARY_IMPLICIT_EXPORTS", "ANDROID_LIBRARY_IMPLICIT_EXPORTS_GENERATOR_FUNCTIONS")
 load("@rules_android//rules/acls:android_library_resources_without_srcs.bzl", "ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS", "ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS_GENERATOR_FUNCTIONS")
+load("@rules_android//rules/acls:android_library_starlark_resource_outputs.bzl", "ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_FALLBACK", "ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_ROLLOUT")
 load("@rules_android//rules/acls:android_lint_checks_rollout.bzl", "ANDROID_LINT_CHECKS_FALLBACK", "ANDROID_LINT_CHECKS_ROLLOUT")
 load("@rules_android//rules/acls:android_lint_rollout.bzl", "ANDROID_LINT_FALLBACK", "ANDROID_LINT_ROLLOUT")
+load("@rules_android//rules/acls:lint_registry_rollout.bzl", "LINT_REGISTRY_FALLBACK", "LINT_REGISTRY_ROLLOUT")
 load("@rules_android//rules/acls:android_build_stamping_rollout.bzl", "ANDROID_BUILD_STAMPING_FALLBACK", "ANDROID_BUILD_STAMPING_ROLLOUT")
 load("@rules_android//rules/acls:b122039567.bzl", "B122039567")
 load("@rules_android//rules/acls:b123854163.bzl", "B123854163")
 load("@rules_android//rules/acls:dex2oat_opts.bzl", "CAN_USE_DEX2OAT_OPTIONS")
-load("@rules_android//rules/acls:fix_application_id.bzl", "FIX_APPLICATION_ID_FALLBACK", "FIX_APPLICATION_ID_ROLLOUT")
 load("@rules_android//rules/acls:fix_export_exporting_rollout.bzl", "FIX_EXPORT_EXPORTING_FALLBACK", "FIX_EXPORT_EXPORTING_ROLLOUT")
 load("@rules_android//rules/acls:fix_resource_transitivity_rollout.bzl", "FIX_RESOURCE_TRANSITIVITY_FALLBACK", "FIX_RESOURCE_TRANSITIVITY_ROLLOUT")
 load("@rules_android//rules/acls:host_dex2oat_rollout.bzl", "AIT_USE_HOST_DEX2OAT_ROLLOUT", "AIT_USE_HOST_DEX2OAT_ROLLOUT_FALLBACK")
@@ -65,6 +66,8 @@
     "PARTIAL_JETIFICATION_TARGETS_ROLLOUT",
 )
 load("@rules_android//rules/acls:kt_android_library_rollout.bzl", "KT_ANDROID_LIBRARY_FALLBACK", "KT_ANDROID_LIBRARY_ROLLOUT")
+load("@rules_android//rules/acls:android_instrumentation_test_manifest_check_rollout.bzl", "ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_FALLBACK", "ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_ROLLOUT")
+load("@rules_android//rules/acls:android_instrumentation_derived_test_class_rollout.bzl", "ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_FALLBACK", "ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_ROLLOUT")
 
 def _in_aar_import_deps_checker(fqn):
     return not _matches(fqn, AAR_IMPORT_DEPS_CHECKER_FALLBACK_DICT) and _matches(fqn, AAR_IMPORT_DEPS_CHECKER_ROLLOUT_DICT)
@@ -102,6 +105,9 @@
 def _in_android_lint_rollout(fqn):
     return not _matches(fqn, ANDROID_LINT_FALLBACK_DICT) and _matches(fqn, ANDROID_LINT_ROLLOUT_DICT)
 
+def _in_lint_registry_rollout(fqn):
+    return not _matches(fqn, LINT_REGISTRY_FALLBACK_DICT) and _matches(fqn, LINT_REGISTRY_ROLLOUT_DICT)
+
 def _in_android_build_stamping_rollout(fqn):
     return not _matches(fqn, ANDROID_BUILD_STAMPING_FALLBACK_DICT) and _matches(fqn, ANDROID_BUILD_STAMPING_ROLLOUT_DICT)
 
@@ -128,15 +134,15 @@
 def _in_android_library_resources_without_srcs_generator_functions(gfn):
     return gfn in ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS_GENERATOR_FUNCTIONS_DICT
 
+def _in_android_library_starlark_resource_outputs_rollout(fqn):
+    return not _matches(fqn, ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_FALLBACK_DICT) and _matches(fqn, ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_ROLLOUT_DICT)
+
 def _in_app_installation_snapshot(fqn):
     return not _matches(fqn, APP_INSTALLATION_SNAPSHOT_FALLBACK_DICT) and _matches(fqn, APP_INSTALLATION_SNAPSHOT_DICT)
 
 def _in_dex2oat_opts(fqn):
     return _matches(fqn, CAN_USE_DEX2OAT_OPTIONS_DICT)
 
-def _in_fix_application_id(fqn):
-    return not _matches(fqn, FIX_APPLICATION_ID_FALLBACK_DICT) and _matches(fqn, FIX_APPLICATION_ID_ROLLOUT_DICT)
-
 def _in_fix_export_exporting_rollout(fqn):
     return not _matches(fqn, FIX_EXPORT_EXPORTING_FALLBACK_DICT) and _matches(fqn, FIX_EXPORT_EXPORTING_ROLLOUT_DICT)
 
@@ -176,6 +182,12 @@
 def _in_kt_android_library_rollout(fqn):
     return not _matches(fqn, KT_ANDROID_LIBRARY_FALLBACK_DICT) and _matches(fqn, KT_ANDROID_LIBRARY_ROLLOUT_DICT)
 
+def _in_android_instrumentation_test_manifest_check_rollout(fqn):
+    return not _matches(fqn, ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_FALLBACK_DICT) and _matches(fqn, ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_ROLLOUT_DICT)
+
+def _in_android_instrumentation_test_derived_test_class_rollout(fqn):
+    return not _matches(fqn, ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_FALLBACK_DICT) and _matches(fqn, ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_ROLLOUT_DICT)
+
 def _make_dict(lst):
     """Do not use this method outside of this file."""
     return {t: True for t in lst}
@@ -199,10 +211,14 @@
 ANDROID_LIBRARY_IMPLICIT_EXPORTS_GENERATOR_FUNCTIONS_DICT = _make_dict(ANDROID_LIBRARY_IMPLICIT_EXPORTS_GENERATOR_FUNCTIONS)
 ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS_DICT = _make_dict(ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS)
 ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS_GENERATOR_FUNCTIONS_DICT = _make_dict(ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS_GENERATOR_FUNCTIONS)
+ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_FALLBACK_DICT = _make_dict(ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_FALLBACK)
+ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_ROLLOUT_DICT = _make_dict(ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_ROLLOUT)
 ANDROID_LINT_CHECKS_FALLBACK_DICT = _make_dict(ANDROID_LINT_CHECKS_FALLBACK)
 ANDROID_LINT_CHECKS_ROLLOUT_DICT = _make_dict(ANDROID_LINT_CHECKS_ROLLOUT)
 ANDROID_LINT_FALLBACK_DICT = _make_dict(ANDROID_LINT_FALLBACK)
 ANDROID_LINT_ROLLOUT_DICT = _make_dict(ANDROID_LINT_ROLLOUT)
+LINT_REGISTRY_FALLBACK_DICT = _make_dict(LINT_REGISTRY_FALLBACK)
+LINT_REGISTRY_ROLLOUT_DICT = _make_dict(LINT_REGISTRY_ROLLOUT)
 ANDROID_BUILD_STAMPING_ROLLOUT_DICT = _make_dict(ANDROID_BUILD_STAMPING_ROLLOUT)
 ANDROID_BUILD_STAMPING_FALLBACK_DICT = _make_dict(ANDROID_BUILD_STAMPING_FALLBACK)
 ANDROID_TEST_LOCKDOWN_GENERATOR_FUNCTIONS_DICT = _make_dict(ANDROID_TEST_LOCKDOWN_GENERATOR_FUNCTIONS)
@@ -212,8 +228,6 @@
 B122039567_DICT = _make_dict(B122039567)
 B123854163_DICT = _make_dict(B123854163)
 CAN_USE_DEX2OAT_OPTIONS_DICT = _make_dict(CAN_USE_DEX2OAT_OPTIONS)
-FIX_APPLICATION_ID_FALLBACK_DICT = _make_dict(FIX_APPLICATION_ID_FALLBACK)
-FIX_APPLICATION_ID_ROLLOUT_DICT = _make_dict(FIX_APPLICATION_ID_ROLLOUT)
 FIX_RESOURCE_TRANSIVITY_FALLBACK_DICT = _make_dict(FIX_RESOURCE_TRANSITIVITY_FALLBACK)
 FIX_RESOURCE_TRANSIVITY_ROLLOUT_DICT = _make_dict(FIX_RESOURCE_TRANSITIVITY_ROLLOUT)
 FIX_EXPORT_EXPORTING_FALLBACK_DICT = _make_dict(FIX_EXPORT_EXPORTING_FALLBACK)
@@ -237,6 +251,10 @@
 PARTIAL_JETIFICATION_TARGETS_FALLBACK_DICT = _make_dict(PARTIAL_JETIFICATION_TARGETS_FALLBACK)
 KT_ANDROID_LIBRARY_ROLLOUT_DICT = _make_dict(KT_ANDROID_LIBRARY_ROLLOUT)
 KT_ANDROID_LIBRARY_FALLBACK_DICT = _make_dict(KT_ANDROID_LIBRARY_FALLBACK)
+ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_ROLLOUT_DICT = _make_dict(ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_ROLLOUT)
+ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_FALLBACK_DICT = _make_dict(ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_FALLBACK)
+ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_ROLLOUT_DICT = _make_dict(ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_ROLLOUT)
+ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_FALLBACK_DICT = _make_dict(ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_FALLBACK)
 
 def _matches(fqn, dct):
     # Labels with workspace names ("@workspace//pkg:target") are not supported.
@@ -288,15 +306,16 @@
     in_android_feature_splits_dogfood = _in_android_feature_splits_dogfood,
     in_android_library_implicit_exports = _in_android_library_implicit_exports,
     in_android_library_implicit_exports_generator_functions = _in_android_library_implicit_exports_generator_functions,
+    in_android_library_starlark_resource_outputs_rollout = _in_android_library_starlark_resource_outputs_rollout,
     in_android_library_resources_without_srcs = _in_android_library_resources_without_srcs,
     in_android_library_resources_without_srcs_generator_functions = _in_android_library_resources_without_srcs_generator_functions,
     in_android_lint_checks_rollout = _in_android_lint_checks_rollout,
     in_android_lint_rollout = _in_android_lint_rollout,
+    in_lint_registry_rollout = _in_lint_registry_rollout,
     in_android_build_stamping_rollout = _in_android_build_stamping_rollout,
     in_android_test_lockdown_allowlist = _in_android_test_lockdown_allowlist,
     in_app_installation_snapshot = _in_app_installation_snapshot,
     in_dex2oat_opts = _in_dex2oat_opts,
-    in_fix_application_id = _in_fix_application_id,
     in_fix_export_exporting_rollout = _in_fix_export_exporting_rollout,
     in_fix_resource_transivity_rollout = _in_fix_resource_transivity_rollout,
     in_host_dex2oat_rollout = _in_host_dex2oat_rollout,
@@ -310,6 +329,8 @@
     in_allow_resource_conflicts = _in_allow_resource_conflicts,
     in_partial_jetification_targets = _in_partial_jetification_targets,
     in_kt_android_library_rollout = _in_kt_android_library_rollout,
+    in_android_instrumentation_test_manifest_check_rollout = _in_android_instrumentation_test_manifest_check_rollout,
+    in_android_instrumentation_test_derived_test_class_rollout = _in_android_instrumentation_test_derived_test_class_rollout,
 )
 
 # Visible for testing
diff --git a/rules/acls/fix_application_id.bzl b/rules/acls/android_instrumentation_derived_test_class_rollout.bzl
similarity index 65%
copy from rules/acls/fix_application_id.bzl
copy to rules/acls/android_instrumentation_derived_test_class_rollout.bzl
index 41c18b7..782beb8 100644
--- a/rules/acls/fix_application_id.bzl
+++ b/rules/acls/android_instrumentation_derived_test_class_rollout.bzl
@@ -1,4 +1,4 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
+# Copyright 2021 The Bazel Authors. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -12,16 +12,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""Allowlist for fixing the implicit application ID in manifest processing.
+"""Rollout list for enabling test class derivation in android_instrumentation_test,"""
 
-See b/111923269 for context.
-"""
-
-# keep sorted
-FIX_APPLICATION_ID_ROLLOUT = [
+ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_ROLLOUT = [
     "//:__subpackages__",
 ]
 
-# keep sorted
-FIX_APPLICATION_ID_FALLBACK = [
+ANDROID_INSTRUMENTATION_TEST_DERIVED_TEST_CLASS_FALLBACK = [
+    "//javatests/notinacl:__subpackages__",
 ]
diff --git a/rules/acls/fix_application_id.bzl b/rules/acls/android_instrumentation_test_manifest_check_rollout.bzl
similarity index 75%
rename from rules/acls/fix_application_id.bzl
rename to rules/acls/android_instrumentation_test_manifest_check_rollout.bzl
index 41c18b7..154f6bb 100644
--- a/rules/acls/fix_application_id.bzl
+++ b/rules/acls/android_instrumentation_test_manifest_check_rollout.bzl
@@ -12,16 +12,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""Allowlist for fixing the implicit application ID in manifest processing.
+"""Rollout list for enabling manifest validation in android_instrumentation_test."""
 
-See b/111923269 for context.
-"""
-
-# keep sorted
-FIX_APPLICATION_ID_ROLLOUT = [
+ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_ROLLOUT = [
     "//:__subpackages__",
 ]
 
-# keep sorted
-FIX_APPLICATION_ID_FALLBACK = [
+ANDROID_INSTRUMENTATION_TEST_MANIFEST_CHECK_FALLBACK = [
 ]
diff --git a/rules/acls/android_library_starlark_resource_outputs.bzl b/rules/acls/android_library_starlark_resource_outputs.bzl
new file mode 100644
index 0000000..b798fa3
--- /dev/null
+++ b/rules/acls/android_library_starlark_resource_outputs.bzl
@@ -0,0 +1,26 @@
+# Copyright 2021 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Allow list for setting the resource outputs (.srcjar, R.txt, and _resources.jar) of android_library to
+those files generated by the Starlark resource processing pipeline and not the native resource
+processing pipeline. These resource-related predeclared outputs need to be re-pointed to the corresponding
+artifacts in the Starlark pipeline. See b/177261846."""
+
+# keep sorted
+ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_ROLLOUT = [
+    "//:__subpackages__",
+]
+
+ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_FALLBACK = [
+]
diff --git a/rules/acls/fix_application_id.bzl b/rules/acls/lint_registry_rollout.bzl
similarity index 67%
copy from rules/acls/fix_application_id.bzl
copy to rules/acls/lint_registry_rollout.bzl
index 41c18b7..3138f94 100644
--- a/rules/acls/fix_application_id.bzl
+++ b/rules/acls/lint_registry_rollout.bzl
@@ -1,4 +1,4 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
+# Copyright 2021 The Bazel Authors. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -12,16 +12,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""Allowlist for fixing the implicit application ID in manifest processing.
-
-See b/111923269 for context.
-"""
+"""Allow list for the Android Lint Registry target."""
 
 # keep sorted
-FIX_APPLICATION_ID_ROLLOUT = [
-    "//:__subpackages__",
+LINT_REGISTRY_ROLLOUT = [
 ]
 
-# keep sorted
-FIX_APPLICATION_ID_FALLBACK = [
-]
+LINT_REGISTRY_FALLBACK = []
diff --git a/rules/android_application/android_feature_module_rule.bzl b/rules/android_application/android_feature_module_rule.bzl
index 87c57b5..3041656 100644
--- a/rules/android_application/android_feature_module_rule.bzl
+++ b/rules/android_application/android_feature_module_rule.bzl
@@ -121,6 +121,7 @@
     tags = getattr(attrs, "tags", [])
     transitive_configs = getattr(attrs, "transitive_configs", [])
     visibility = getattr(attrs, "visibility", None)
+    testonly = getattr(attrs, "testonly", None)
 
     # Create strings.xml containing split title
     title_id = "split_" + str(hash(fqn)).replace("-", "N")
@@ -164,6 +165,7 @@
         tags = tags,
         transitive_configs = transitive_configs,
         visibility = visibility,
+        testonly = testonly,
     )
 
     # Wrap any deps in an android_binary. Will be validated to ensure does not contain any dexes
@@ -178,6 +180,7 @@
         "visibility": visibility,
         "feature_flags": getattr(attrs, "feature_flags", None),
         "$enable_manifest_merging": False,
+        "testonly": testonly,
     }
     _android_binary(**binary_attrs)
 
@@ -193,4 +196,5 @@
         tags = tags,
         transitive_configs = transitive_configs,
         visibility = visibility,
+        testonly = testonly,
     )
diff --git a/rules/android_library/attrs.bzl b/rules/android_library/attrs.bzl
index b71b466..8e38b01 100644
--- a/rules/android_library/attrs.bzl
+++ b/rules/android_library/attrs.bzl
@@ -66,6 +66,7 @@
         _flags = attr.label(
             default = "@rules_android//rules/flags",
         ),
+        _package_name = attr.string(),  # for sending the package name to the outputs callback
     ),
     _attrs.COMPILATION,
     _attrs.DATA_CONTEXT,
diff --git a/rules/android_library/rule.bzl b/rules/android_library/rule.bzl
index f267b37..02cc1fc 100644
--- a/rules/android_library/rule.bzl
+++ b/rules/android_library/rule.bzl
@@ -14,6 +14,7 @@
 
 """android_library rule."""
 
+load("@rules_android//rules:acls.bzl", "acls")
 load(":attrs.bzl", _ATTRS = "ATTRS")
 load(":impl.bzl", _impl = "impl")
 load(
@@ -21,7 +22,7 @@
     _attrs = "attrs",
 )
 
-def _outputs(_defined_local_resources):
+def _outputs(name, _package_name, _defined_local_resources):
     outputs = dict(
         lib_jar = "lib%{name}.jar",
         lib_src_jar = "lib%{name}-src.jar",
@@ -31,11 +32,16 @@
     if _defined_local_resources:
         # TODO(b/177261846): resource-related predeclared outputs need to be re-pointed at the
         # corresponding artifacts in the Starlark pipeline.
+        label = "//" + _package_name + ":" + name
+        if acls.in_android_library_starlark_resource_outputs_rollout(label):
+            path_prefix = "_migrated/"
+        else:
+            path_prefix = ""
         outputs.update(
             dict(
-                resources_src_jar = "_migrated/%{name}.srcjar",
-                resources_txt = "_migrated/%{name}_symbols/R.txt",
-                resources_jar = "_migrated/%{name}_resources.jar",
+                resources_src_jar = path_prefix + "%{name}.srcjar",
+                resources_txt = path_prefix + "%{name}_symbols/R.txt",
+                resources_jar = path_prefix + "%{name}_resources.jar",
             ),
         )
 
@@ -51,6 +57,8 @@
     Args:
       attrs: A dict. The attributes for the rule.
       implementation: A function. The rule's implementation method.
+      outputs: A dict, function, or None. The rule's outputs.
+      additional_toolchains: A list. Additional toolchains passed to pass to rule(toolchains).
 
     Returns:
       A rule.
@@ -122,6 +130,11 @@
     attrs["$defined_idl_import_root"] = _is_defined("idl_import_root", attrs)
     attrs["$defined_idl_parcelables"] = _is_defined("idl_parcelables", attrs)
     attrs["$defined_idl_srcs"] = _is_defined("idl_srcs", attrs)
+
+    # Required for ACLs check in _outputs(), since the callback can't access
+    # the native module.
+    attrs["$package_name"] = native.package_name()
+
     return attrs
 
 def android_library_macro(**attrs):
diff --git a/rules/bundletool.bzl b/rules/bundletool.bzl
index 07f5217..161882a 100644
--- a/rules/bundletool.bzl
+++ b/rules/bundletool.bzl
@@ -16,6 +16,16 @@
 
 load(":java.bzl", _java = "java")
 
+_density_mapping = {
+    "ldpi": 120,
+    "mdpi": 160,
+    "hdpi": 240,
+    "xhdpi": 320,
+    "xxhdpi": 480,
+    "xxxhdpi": 640,
+    "tvdpi": 213,
+}
+
 def _proto_apk_to_module(
         ctx,
         out = None,
@@ -72,7 +82,7 @@
 fi
 
 cd "${OUT_DIR}"
-"${CUR_PWD}/${ZIP}" "${CUR_PWD}/${OUTPUT}" -Drqq .
+"${CUR_PWD}/${ZIP}" "${CUR_PWD}/${OUTPUT}" -Drq0 .
 """ % (
             unzip.executable.path,
             zip.executable.path,
@@ -182,8 +192,71 @@
         command = cmd,
     )
 
+def _bundle_to_apks(
+        ctx,
+        out = None,
+        bundle = None,
+        universal = False,
+        device_spec = None,
+        keystore = None,
+        modules = None,
+        aapt2 = None,
+        bundletool = None,
+        host_javabase = None):
+    inputs = [bundle]
+    args = ctx.actions.args()
+    args.add("build-apks")
+    args.add("--output", out)
+    args.add("--bundle", bundle)
+    args.add("--aapt2", aapt2.executable.path)
+
+    if universal:
+        args.add("--mode=universal")
+
+    if keystore:
+        args.add("--ks", keystore.path)
+        args.add("--ks-pass", "pass:android")
+        args.add("--ks-key-alias", "AndroidDebugKey")
+        inputs.append(keystore)
+
+    if device_spec:
+        args.add("--device-spec", device_spec)
+        inputs.append(device_spec)
+
+    if modules:
+        args.add_joined("--modules", modules, join_with = ",")
+
+    _java.run(
+        ctx = ctx,
+        host_javabase = host_javabase,
+        executable = bundletool,
+        arguments = [args],
+        inputs = inputs,
+        outputs = [out],
+        tools = [aapt2],
+        mnemonic = "BundleToApks",
+        progress_message = "Converting bundle to .apks: %s" % out.short_path,
+    )
+
+def _build_device_json(
+        ctx,
+        out,
+        abis,
+        locales,
+        density,
+        sdk_version):
+    json_content = json.encode(struct(
+        supportedAbis = abis,
+        supportedLocales = locales,
+        screenDensity = _density_mapping[density],
+        sdkVersion = int(sdk_version),
+    ))
+    ctx.actions.write(out, json_content)
+
 bundletool = struct(
     build = _build,
+    build_device_json = _build_device_json,
+    bundle_to_apks = _bundle_to_apks,
     extract_config = _extract_config,
     extract_manifest = _extract_manifest,
     proto_apk_to_module = _proto_apk_to_module,
diff --git a/rules/busybox.bzl b/rules/busybox.bzl
index f0d78ac..a92fe68 100644
--- a/rules/busybox.bzl
+++ b/rules/busybox.bzl
@@ -191,6 +191,7 @@
         resource_configs = None,
         densities = [],
         application_id = None,
+        package_id = None,
         direct_resources_nodes = [],
         transitive_resources_nodes = [],
         transitive_manifests = [],
@@ -233,6 +234,11 @@
       densities: A list of strings. The list of screen densities to filter for when
         building the apk.
       application_id: An optional string. The applicationId set in manifest values.
+      package_id: An optional integer in [2,255]. This is the prefix byte for
+        all generated resource IDs, defaults to 0x7F (127). 1 is reserved by the
+        framework, and some builds are known to crash when given IDs > 127.
+        Shared libraries are also assigned monotonically increasing IDs in
+        [2,126], so care should be taken that there is room at the lower end.
       direct_resources_nodes: Depset of ResourcesNodeInfo providers. The set of
         ResourcesNodeInfo from direct dependencies.
       transitive_resources_nodes: Depset of ResourcesNodeInfo providers. The set
@@ -356,6 +362,8 @@
         args.add_joined("--densities", _extract_filters(densities), join_with = ",")
     if application_id:
         args.add("--applicationId", application_id)
+    if package_id:
+        args.add("--packageId", package_id)
     if additional_apks_to_link_against:
         args.add_joined(
             "--additionalApksToLinkAgainst",
@@ -372,7 +380,8 @@
         args.add("--versionName", version_name)
     if version_code:
         args.add("--versionCode", version_code)
-    args.add("--packageForR", java_package)
+    if java_package:
+        args.add("--packageForR", java_package)
 
     _java.run(
         ctx = ctx,
@@ -792,7 +801,7 @@
         fail("Unexpected manifest merge type: " + merge_type)
 
     outputs = [out_file]
-    directs = [manifest]
+    directs = [manifest] if manifest else []
     transitives = [mergee_manifests]
 
     # Args for busybox
@@ -800,7 +809,8 @@
     args.use_param_file("@%s", use_always = True)
     args.add("--tool", "MERGE_MANIFEST")
     args.add("--")
-    args.add("--manifest", manifest)
+    if manifest:
+        args.add("--manifest", manifest)
     args.add_all(
         "--mergeeManifests",
         [mergee_manifests],
@@ -812,7 +822,8 @@
             ",".join(["%s:%s" % (_escape_mv(k), _escape_mv(v)) for k, v in manifest_values.items()]),
         )
     args.add("--mergeType", merge_type)
-    args.add("--customPackage", java_package)
+    if java_package:
+        args.add("--customPackage", java_package)
     args.add("--manifestOutput", out_file)
     if out_log_file:
         args.add("--log", out_log_file)
@@ -919,7 +930,8 @@
     args.add("--")
     args.add("--primaryRTxt", r_txt)
     args.add("--primaryManifest", manifest)
-    args.add("--packageForR", package_for_r)
+    if package_for_r:
+        args.add("--packageForR", package_for_r)
     args.add_all(
         resources_nodes,
         map_each = _make_generate_binay_r_flags,
@@ -933,6 +945,7 @@
     # TODO(b/154003916): support transitive "--library transitive_r_txt_path,transitive_manifest_path" flags
     args.add("--classJarOutput", out_class_jar)
     args.add("--targetLabel", str(ctx.label))
+    args.use_param_file("@%s")
 
     _java.run(
         ctx = ctx,
diff --git a/rules/data_binding.bzl b/rules/data_binding.bzl
index 70df90f..9243673 100644
--- a/rules/data_binding.bzl
+++ b/rules/data_binding.bzl
@@ -66,15 +66,27 @@
     args.add("-zipSourceOutput", "true")
     args.add("-useAndroidX", "false")
 
-    class_infos = []
-    for info in deps:
-        class_infos.extend(info.class_infos)
+    if deps:
+        if type(deps[0].class_infos) == "depset":
+            class_infos = depset(transitive = [info.class_infos for info in deps])
+            inputs = depset(direct = [layout_info], transitive = [class_infos])
+        elif type(deps[0].class_infos) == "list":
+            class_infos = []
+            for info in deps:
+                class_infos.extend(info.class_infos)
+            inputs = class_infos + [layout_info]
+        else:
+            fail("Expected list or depset. Got %s" % type(deps[0].class_infos))
+    else:
+        class_infos = []
+        inputs = [layout_info]
+
     args.add_all(class_infos, before_each = "-dependencyClassInfoList")
 
     ctx.actions.run(
         executable = data_binding_exec,
         arguments = ["GEN_BASE_CLASSES", args],
-        inputs = class_infos + [layout_info],
+        inputs = inputs,
         outputs = [class_info, srcjar],
         mnemonic = "GenerateDataBindingBaseClasses",
         progress_message = (
@@ -91,8 +103,8 @@
     for info in deps:
         # Yes, DataBinding requires depsets iterations.
         for artifact in (info.transitive_br_files.to_list() +
-                         info.setter_stores +
-                         info.class_infos):
+                         _utils.list_or_depset_to_list(info.setter_stores) +
+                         _utils.list_or_depset_to_list(info.class_infos)):
             # short_path might contain a parent directory reference if the
             # databinding artifact is from an external repository (e.g. an aar
             # from Maven). If that's the case, just remove the parent directory
@@ -208,7 +220,7 @@
         ]
         return struct(**db_info)
 
-    output_dir = "_migrated/databinding/%s/" % ctx.label.name
+    output_dir = "databinding/%s/" % ctx.label.name
 
     db_info[_JAVA_SRCS].append(_copy_annotation_file(
         ctx,
diff --git a/rules/flags/flag_defs.bzl b/rules/flags/flag_defs.bzl
index 7b9a8d8..08eee2d 100644
--- a/rules/flags/flag_defs.bzl
+++ b/rules/flags/flag_defs.bzl
@@ -31,7 +31,7 @@
 
     flags.DEFINE_int(
         name = "num_dex_shards",
-        default = 16,
+        default = 32,
         description = "Number of dex shards to use for mobile-install.",
     )
 
@@ -64,7 +64,7 @@
 
     flags.DEFINE_bool(
         name = "enable_splits",
-        default = False,
+        default = True,
         description = "Build and install split apks if the device supports them.",
     )
 
diff --git a/rules/java.bzl b/rules/java.bzl
index 42470f0..2e2fc58 100644
--- a/rules/java.bzl
+++ b/rules/java.bzl
@@ -14,7 +14,6 @@
 
 """Bazel Java APIs for the Android rules."""
 
-load(":acls.bzl", "acls")
 load(":path.bzl", _path = "path")
 load(":utils.bzl", "log")
 
@@ -89,8 +88,7 @@
 
 def _resolve_package_from_label(
         label,
-        custom_package = None,
-        fallback = True):
+        custom_package = None):
     """Resolves the Java package from a Label.
 
     When no legal Java package can be resolved from the label, None will be
@@ -111,15 +109,7 @@
         [label.package] +
         _path.split(label.name)[:-1],
     )
-    java_package = _resolve_package(label_path)
-
-    if java_package != None:  # "" is a valid result.
-        return java_package
-
-    if fallback:
-        return label.package.replace("/", ".")
-
-    return None
+    return _resolve_package(label_path)
 
 def _root(path):
     """Determines the Java root from the given path.
@@ -169,29 +159,6 @@
         (not custom_package and _check_for_invalid_java_package(java_package))
     )
 
-def _set_default_applicationid(fqn, attrs):
-    """Sets the manifest value applicationId to the package.
-
-    If applicationId is missing from the manifest_values, set it
-    to the package as a default value to avoid using library packages
-    when merging manifests.
-    """
-    if not acls.in_fix_application_id(fqn):
-        return attrs
-    new_attrs = {}
-    new_attrs.update(attrs)
-    package_string = _resolve_package_from_label(Label(fqn), None)
-
-    # TODO(timpeut): handle select()s
-    mv_attr = attrs.get("manifest_values", None) or {}
-    if type(mv_attr) == "dict" and "applicationId" not in mv_attr:
-        manifest_values = {}
-        manifest_values.update(mv_attr)
-        manifest_values.update({"__INTERNAL_PKG_DO_NOT_USE__": package_string})
-        new_attrs["manifest_values"] = manifest_values
-
-    return new_attrs
-
 # The Android specific Java compile.
 def _compile_android(
         ctx,
@@ -227,8 +194,8 @@
       r_java: JavaInfo. The R.jar dependency. Optional.
       deps: sequence of JavaInfo providers. A list of dependencies. Optional.
       exports: sequence of JavaInfo providers. A list of exports. Optional.
-      plugins: sequence of JavaInfo providers. A list of plugins. Optional.
-      exported_plugins: sequence of JavaInfo providers. A list of exported
+      plugins: sequence of JavaPluginInfo providers. A list of plugins. Optional.
+      exported_plugins: sequence of JavaPluginInfo providers. A list of exported
         plugins. Optional.
       annotation_processor_additional_outputs: sequence of Files. A list of
         files produced by an annotation processor.
@@ -327,8 +294,8 @@
         Optional.
       deps: sequence of JavaInfo providers. A list of dependencies. Optional.
       exports: sequence of JavaInfo providers. A list of exports. Optional.
-      plugins: sequence of JavaInfo providers. A list of plugins. Optional.
-      exported_plugins: sequence of JavaInfo providers. A list of exported
+      plugins: sequence of JavaPluginInfo providers. A list of plugins. Optional.
+      exported_plugins: sequence of JavaPluginInfo providers. A list of exported
         plugins. Optional.
       annotation_processor_additional_outputs: sequence of Files. A list of
         files produced by an annotation processor.
@@ -406,6 +373,9 @@
         args.add("--sources")
         args.add_all(inputs)
 
+    args.use_param_file("@%s")
+    args.set_param_file_format("multiline")
+
     ctx.actions.run(
         executable = java_toolchain[java_common.JavaToolchainInfo].single_jar,
         arguments = [args],
@@ -469,7 +439,6 @@
     resolve_package = _resolve_package,
     resolve_package_from_label = _resolve_package_from_label,
     root = _root,
-    set_default_applicationid = _set_default_applicationid,
     invalid_java_package = _invalid_java_package,
     run = _run,
     singlejar = _singlejar,
diff --git a/rules/resources.bzl b/rules/resources.bzl
index 9bebb87..2ad89c6 100644
--- a/rules/resources.bzl
+++ b/rules/resources.bzl
@@ -60,11 +60,6 @@
     "both empty or non-empty."
 )
 
-_JAVA_PACKAGE_MISSING_ERROR = (
-    "In target %s, a java package is required when stamping " +
-    "the manifest."
-)
-
 _INCORRECT_RESOURCE_LAYOUT_ERROR = (
     "'%s' is not in the expected resource directory structure of " +
     "<resource directory>/{%s}/<file>" % (",").join(_RESOURCE_FOLDER_TYPES)
@@ -139,7 +134,7 @@
         min_sdk_version = None):
     content = """<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="%s">""" % java_package
+    package="%s">""" % (java_package or "com.default")
 
     if min_sdk_version:
         content = content + """
@@ -316,6 +311,7 @@
       ctx: The context.
       out_compiled_resources: File. The modified compiled_resources output.
       compiled_resources: File. The compiled_resources zip.
+      zip_tool: FilesToRunProvider. The zip tool executable or FilesToRunProvider
     """
     ctx.actions.run_shell(
         outputs = [out_compiled_resources],
@@ -420,6 +416,7 @@
         resource_files = [],
         nocompress_extensions = [],
         java_package = None,
+        package_id = None,
         compilation_mode = _compilation_mode.FASTBUILD,
         shrink_resources = None,
         use_android_resource_shrinking = None,
@@ -460,6 +457,11 @@
       java_package: String. Java package for which java sources will be
         generated. By default the package is inferred from the directory where
         the BUILD file containing the rule is.
+      package_id: An optional integer in [2,255]. This is the prefix byte for
+        all generated resource IDs, defaults to 0x7F (127). 1 is reserved by the
+        framework, and some builds are known to crash when given IDs > 127.
+        Shared libraries are also assigned monotonically increasing IDs in
+        [2,126], so care should be taken that there is room at the lower end.
       compilation_mode: String. A string that represents compilation mode. The
         list of expected values are as follows: dbg, fastbuild, opt.
       shrink_resources: Tristate. Whether resource shrinking is enabled by the rule.
@@ -579,7 +581,7 @@
     processed_resources = resource_files
     data_binding_layout_info = None
     if enable_data_binding:
-        data_binding_layout_info = ctx.actions.declare_file("_migrated/databinding/" + ctx.label.name + "/layout-info.zip")
+        data_binding_layout_info = ctx.actions.declare_file("_migrated/" + ctx.label.name + "/layout-info.zip")
         processed_resources, resources_dirname = _make_databinding_outputs(
             ctx,
             resource_files,
@@ -620,6 +622,7 @@
         out_main_dex_proguard_cfg = main_dex_proguard_cfg,
         out_resource_files_zip = resource_files_zip,
         application_id = manifest_values.get("applicationId", None),
+        package_id = package_id,
         manifest = merged_manifest,
         assets = assets,
         assets_dir = assets_dir,
@@ -1092,9 +1095,6 @@
     if resource_files and not manifest:
         _log.error(_MANIFEST_MISSING_ERROR % ctx.label)
 
-    if stamp_manifest and not java_package:
-        _log.error(_JAVA_PACKAGE_MISSING_ERROR % ctx.label)
-
     direct_resources_nodes = []
     transitive_resources_nodes = []
     transitive_assets = []
diff --git a/rules/rules.bzl b/rules/rules.bzl
index 2a0a585..315fd4f 100644
--- a/rules/rules.bzl
+++ b/rules/rules.bzl
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""Skylark rules for building Android apps."""
+"""Starlark rules for building Android apps."""
 
 load(
     "//rules/aar_import:rule.bzl",
@@ -20,7 +20,7 @@
 )
 load(
     "//rules/android_application:android_application.bzl",
-     _android_application = "android_application"
+    _android_application = "android_application",
 )
 load(
     ":android_binary.bzl",
diff --git a/rules/utils.bzl b/rules/utils.bzl
index 5bd764e..d796371 100644
--- a/rules/utils.bzl
+++ b/rules/utils.bzl
@@ -195,6 +195,14 @@
         _error("Expected one element, has %s." % len(collection))
     return _first(collection)
 
+def _list_or_depset_to_list(list_or_depset):
+    if type(list_or_depset) == "list":
+        return list_or_depset
+    elif type(list_or_depset) == "depset":
+        return list_or_depset.to_list()
+    else:
+        return _error("Expected a list or a depset. Got %s" % type(list_or_depset))
+
 def _copy_file(ctx, src, dest):
     if src.is_directory or dest.is_directory:
         fail("Cannot use copy_file with directories")
@@ -444,6 +452,7 @@
     sanitize_string = _sanitize_string,
     sanitize_java_package = _sanitize_java_package,
     hex = _hex,
+    list_or_depset_to_list = _list_or_depset_to_list,
 )
 
 log = struct(
diff --git a/src/validations/aar_import_checks/BUILD b/src/validations/aar_import_checks/BUILD
index eb11bcf..8f7bb2a 100644
--- a/src/validations/aar_import_checks/BUILD
+++ b/src/validations/aar_import_checks/BUILD
@@ -7,20 +7,21 @@
 genrule(
     name = "gen_aar_import_checks",
     outs = ["aar_import_checks"],
-    executable = True,
     cmd = """
-cat > $@ <<EOF
+cat > $@ <<"EOF"
 #!/bin/bash
 while [[ $$# -gt 0 ]]
 do
-case $$1 in
-    -output)
-    out="$$2"
-    shift # past argument
-    shift # past value
-    ;;
-esac
+  case $$1 in
+      -output)
+      out="$$2"
+      ;;
+  esac
+  shift # past argument
+  shift # past value
 done
 touch $$out
 EOF
-""")
+""",
+    executable = True,
+)
diff --git a/toolchains/android/toolchain.bzl b/toolchains/android/toolchain.bzl
index a63fe63..42cdf9d 100644
--- a/toolchains/android/toolchain.bzl
+++ b/toolchains/android/toolchain.bzl
@@ -21,89 +21,89 @@
     ),
     aar_import_checks = attr.label(
         allow_single_file = True,
-        cfg = "host",
+        cfg = "exec",
         default = "//src/validations/aar_import_checks",
         executable = True,
     ),
     aar_embedded_jars_extractor = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@bazel_tools//tools/android:aar_embedded_jars_extractor",
         executable = True,
     ),
     aar_embedded_proguard_extractor = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@bazel_tools//tools/android:aar_embedded_proguard_extractor",
         executable = True,
     ),
     aar_native_libs_zip_creator = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@bazel_tools//tools/android:aar_native_libs_zip_creator",
         executable = True,
     ),
     aar_resources_extractor = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@bazel_tools//tools/android:aar_resources_extractor",
         executable = True,
     ),
     adb = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@androidsdk//:platform-tools/adb",
         executable = True,
     ),
     add_g3itr_xslt = attr.label(
-        cfg = "host",
+        cfg = "exec",
         default = Label("//tools/android/xslt:add_g3itr.xslt"),
         allow_files = True,
     ),
     android_archive_jar_optimization_inputs_validator = attr.label(
         allow_files = True,
         default = "@androidsdk//:fail",
-        cfg = "host",
+        cfg = "exec",
         executable = True,
     ),
     android_archive_manifest_package_validator = attr.label(
         allow_files = True,
         default = "@androidsdk//:fail",
-        cfg = "host",
+        cfg = "exec",
         executable = True,
     ),
     android_archive_packages_validator = attr.label(
         allow_files = True,
         default = "@androidsdk//:fail",
-        cfg = "host",
+        cfg = "exec",
         executable = True,
     ),
     android_kit = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@androidsdk//:fail",  # TODO: "//src/tools/ak", needs Go
         executable = True,
     ),
     android_resources_busybox = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@bazel_tools//src/tools/android/java/com/google/devtools/build/android:ResourceProcessorBusyBox_deploy.jar",
         executable = True,
     ),
     apk_to_bundle_tool = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@androidsdk//:fail",
         executable = True,
     ),
     bundletool = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "//tools/android:bundletool_deploy.jar",
         executable = True,
     ),
     data_binding_annotation_processor = attr.label(
-        cfg = "host",
+        cfg = "exec",
         default = "@//tools/android:compiler_annotation_processor",  # TODO: processor rules should be moved into rules_android
     ),
     data_binding_annotation_template = attr.label(
@@ -111,25 +111,25 @@
         allow_files = True,
     ),
     data_binding_exec = attr.label(
-        cfg = "host",
+        cfg = "exec",
         default = "@bazel_tools//tools/android:databinding_exec",
         executable = True,
     ),
     desugar_java8_extra_bootclasspath = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@bazel_tools//tools/android:desugar_java8_extra_bootclasspath",
         executable = True,
     ),
     idlclass = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@bazel_tools//tools/android:IdlClass",  # _deploy.jar?
         executable = True,
     ),
     import_deps_checker = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         default = "@android_tools//:ImportDepsChecker_deploy.jar",
         executable = True,
     ),
@@ -143,18 +143,18 @@
     ),
     jdeps_tool = attr.label(
         allow_files = True,
-        cfg = "host",
+        cfg = "exec",
         # used in android_local_test
         default = "@androidsdk//:fail",  # TODO: "//src/tools/jdeps", needs Go
         executable = True,
     ),
     proguard_allowlister = attr.label(
-        cfg = "host",
+        cfg = "exec",
         default = "@bazel_tools//tools/jdk:proguard_whitelister",
         executable = True,
     ),
     proto_map_generator = attr.label(
-        cfg = "host",
+        cfg = "exec",
         default = "@androidsdk//:fail",
         allow_files = True,
         executable = True,
@@ -175,18 +175,18 @@
         default = "@androidsdk//:fail",
     ),
     unzip_tool = attr.label(
-        cfg = "host",
+        cfg = "exec",
         default = "//toolchains/android:unzip",
         executable = True,
     ),
     xsltproc_tool = attr.label(
-        cfg = "host",
+        cfg = "exec",
         default = Label("//tools/android/xslt:xslt"),
         allow_files = True,
         executable = True,
     ),
     zip_tool = attr.label(
-        cfg = "host",
+        cfg = "exec",
         default = "//toolchains/android:zip",
         executable = True,
     ),
diff --git a/tools/android/BUILD b/tools/android/BUILD
index 61ee16c..cb8148a 100644
--- a/tools/android/BUILD
+++ b/tools/android/BUILD
@@ -13,20 +13,20 @@
 )
 
 genrule(
-  name = "gen_fail",
-  outs = ["fail.sh"],
-  cmd = "echo 'exit 1' > $@",
-  executable = 1,
+    name = "gen_fail",
+    outs = ["fail.sh"],
+    cmd = "echo 'exit 1' > $@",
+    executable = 1,
 )
 
 sh_binary(
-  name = "fail",
-  srcs =[":fail.sh"],
+    name = "fail",
+    srcs = [":fail.sh"],
 )
 
 java_binary(
     name = "bundletool",
     main_class = "com.android.tools.build.bundletool.BundleToolMain",
-    runtime_deps = ["@rules_android_maven//:com_android_tools_build_bundletool"],
     visibility = ["//visibility:public"],
+    runtime_deps = ["@rules_android_maven//:com_android_tools_build_bundletool"],
 )