Open sgowroji opened 10 months ago
Hello, I'm using bazel 7.0.2 right now and I'm facing exactly the same problem. Is there possibility that that issue came back ?
Hey @ted-xie, this looks like Android NDK toolchains problem happening https://github.com/bazelbuild/examples/tree/main/android/jetpack-compose. Could you investigate?
@ted-xie @ahumesky friendly ping
@ted-xie @ahumesky friendly ping
cc @meisterT
I was able to reproduce this (after a small change in the repro instructions that I've edited the original issue for). I think I've seen this before; we should just need some extra flags in bazelrc IIRC.
I think there may be multiple problems with this example. I noticed there was no NDK repository specified anywhere, so I added it:
diff --git a/android/jetpack-compose/WORKSPACE b/android/jetpack-compose/WORKSPACE
index b0325a8..db38a08 100644
--- a/android/jetpack-compose/WORKSPACE
+++ b/android/jetpack-compose/WORKSPACE
@@ -41,3 +41,14 @@ load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()
+http_archive(
+ name = "rules_android_ndk",
+ sha256 = "b1a5ddd784e6ed915c2035c0db536a278b5f50c64412128c06877115991391ef",
+ strip_prefix = "rules_android_ndk-877c68ef34c9f3353028bf490d269230c1990483",
+ url = "https://github.com/bazelbuild/rules_android_ndk/archive/877c68ef34c9f3353028bf490d269230c1990483.zip",
+)
+
+load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")
+
+android_ndk_repository(name = "androidndk")
+
Then when I try to build the example app, there's a different error about a missing Java toolchain:
$ bazelisk build --android_platforms=//:arm64-v8a --remote_download_outputs=all --enable_bzlmod //app/src/main:app
ERROR: /usr/local/google/home/tedx/work/github/bazel_issue_20970/examples/android/jetpack-compose/app/src/main/BUILD.bazel:4:19: While resolving toolchains for target //app/src/main:lib_kt (aadbf16): No matching toolchains found for types @@bazel_tools//tools/jdk:runtime_toolchain_type.
I think overall it may be better to deprecate this jetpack compose example entirely, since rules_kotlin has its own version here that is more actively maintained and closer to the development pulse. @Bencodes
Updating to a more recent rules_kotlin
version seems to make things a little better, but not entirely; at least now there are no more toolchain-related issues.
My patch:
diff --git a/android/jetpack-compose/WORKSPACE b/android/jetpack-compose/WORKSPACE
index b0325a8..2ab68f2 100644
--- a/android/jetpack-compose/WORKSPACE
+++ b/android/jetpack-compose/WORKSPACE
@@ -22,10 +22,15 @@ android_sdk_repository(name = "androidsdk")
## Kotlin
+#http_archive(
+# name = "io_bazel_rules_kotlin",
+# sha256 = "f033fa36f51073eae224f18428d9493966e67c27387728b6be2ebbdae43f140e",
+# url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.7.0-RC-3/rules_kotlin_release.tgz",
+#)
http_archive(
name = "io_bazel_rules_kotlin",
- sha256 = "f033fa36f51073eae224f18428d9493966e67c27387728b6be2ebbdae43f140e",
- url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.7.0-RC-3/rules_kotlin_release.tgz",
+ sha256 = "34e8c0351764b71d78f76c8746e98063979ce08dcf1a91666f3f3bc2949a533d",
+ url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.9.5/rules_kotlin-v1.9.5.tar.gz",
)
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "kotlinc_version")
@@ -41,3 +46,15 @@ load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()
+## NDK
+http_archive(
+ name = "rules_android_ndk",
+ sha256 = "b1a5ddd784e6ed915c2035c0db536a278b5f50c64412128c06877115991391ef",
+ strip_prefix = "rules_android_ndk-877c68ef34c9f3353028bf490d269230c1990483",
+ url = "https://github.com/bazelbuild/rules_android_ndk/archive/877c68ef34c9f3353028bf490d269230c1990483.zip",
+)
+
+load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")
+
+android_ndk_repository(name = "androidndk")
The build:
$ bazelisk build --android_platforms=//:arm64-v8a --remote_download_outputs=all --enable_bzlmod //app/src/main:app
INFO: Analyzed target //app/src/main:app (12 packages loaded, 6078 targets configured).
INFO: From KotlinCompile //app/src/main:lib_kt { kt: 1, java: 0, srcjars: 0 } for k8:
warning: language version 1.9 is experimental, there are no backwards compatibility guarantees for new language and library features
warning: language version 1.9 is experimental, there are no backwards compatibility guarantees for new language and library features
ERROR: /usr/local/google/home/tedx/work/github/bazel_issue_20970/examples/android/jetpack-compose/app/src/main/BUILD.bazel:4:19: output 'app/src/main/lib_kt-kt.jdeps' was not created
ERROR: /usr/local/google/home/tedx/work/github/bazel_issue_20970/examples/android/jetpack-compose/app/src/main/BUILD.bazel:4:19: KotlinCompile //app/src/main:lib_kt { kt: 1, java: 0, srcjars: 0 } for k8 failed: not all outputs were created or valid
I think this needs some input from the rules_kotlin folks on how to proceed.
CI: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/3608#018d2ef4-1d2c-446b-a314-c133272f58d9
Platform: Ubuntu, MacOS
Logs:
Culprit: https://github.com/bazelbuild/bazel/commit/03490b9f72dc479c979afff6b1731a72787cba8b, https://github.com/bazelbuild/bazel/commit/8ba66188e378fe3df5db9549b3b9661d62cf93bb
Steps:
CC Greenteam @comius