bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.21k stars 4.07k forks source link

incompatible_disable_native_android_rules #8391

Open timpeut opened 5 years ago

timpeut commented 5 years ago

As proposed and accepted in Android Native to Starlark Migration we will be disabling all usage of the native Android build rules. Users should be using the Starlark Android Rules.

Migration

  1. Add the following to your WORKSPACE

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    http_archive(
    name = "rules_android",
    urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
    sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
    strip_prefix = "rules_android-0.1.1",
    )
  2. Load all android_* rules in your BUILD and .bzl files:

    load("@rules_android//android:rules.bzl", "android_library")
    android_library(
    ...
    )

We will be updating buildifier to automatically perform step 2, but it is trivial to perform manually.

Expected Timeline

timpeut commented 5 years ago

Flag has been added. Should be released in 0.27

https://github.com/bazelbuild/bazel/commit/6fe6e984c325f91a8c5d69cfef84d3ea4b06c8ef

timpeut commented 5 years ago

And the native-android fix has been added to buildifier

https://github.com/bazelbuild/buildtools/pull/638

cgruber commented 4 years ago

Wait, this didn't go in to 2.0? At this point, this is blocking the rules_kotlin proceeding with fixing this same issue, triggering the following errors:

(03:07:12) ERROR: /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/5a661b0f3ed263c29200a380b053ff64/external/bazel_tools/tools/android/BUILD:10:1: in tags attribute of android_tools_defaults_jar rule @bazel_tools//tools/android:android_jar: The native Android rules are deprecated. Please use the Starlark Android rules by adding the following load statement to the BUILD file: load("@build_bazel_rules_android//android:rules.bzl", "android_tools_defaults_jar"). See http://github.com/bazelbuild/rules_android.
  | (03:07:12) ERROR: /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/5a661b0f3ed263c29200a380b053ff64/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/incrementaldeployment/BUILD:11:1: in tags attribute of android_library rule @bazel_tools//src/tools/android/java/com/google/devtools/build/android/incrementaldeployment:incremental_split_stub_application: The native Android rules are deprecated. Please use the Starlark Android rules by adding the following load statement to the BUILD file: load("@build_bazel_rules_android//android:rules.bzl", "android_library"). See http://github.com/bazelbuild/rules_android.
  | (03:07:12) ERROR: /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/5a661b0f3ed263c29200a380b053ff64/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/incrementaldeployment/BUILD:3:1: in tags attribute of android_library rule @bazel_tools//src/tools/android/java/com/google/devtools/build/android/incrementaldeployment:incremental_stub_application: The native Android rules are deprecated. Please use the Starlark Android rules by adding the following load statement to the BUILD file: load("@build_bazel_rules_android//android:rules.bzl", "android_library"). See http://github.com/bazelbuild/rules_android.
ahumesky commented 3 years ago

@cgruber we won't flip this flag until https://github.com/bazelbuild/bazel/issues/5354 is finished

martis42 commented 2 years ago

This is labeled with breaking-change-5.0, which I interpret as the intention to flip this with Bazel 5.0.0. The flag is however still inactive by default: https://github.com/bazelbuild/bazel/blob/5.0.0/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java#L781

Please update the issue status.

github-actions[bot] commented 1 year ago

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.