No matching toolchains found for types @@bazel_tools//tools/android:sdk_toolchain_type even though called register_toolchains
xiedeacc opened this issue · 2 comments
xiedeacc commented
my use rules_jvm_external to import net.java.dev.jna:jna:aar:5.13.0 by a aar_import came from rules_android. so I followed readme import rules_android in workpsace file, but bazel still cannot find android toolchain, why? how to fix it?
my bazel verison is 7.2.0
INFO: ToolchainResolution: Performing resolution of @@bazel_tools//tools/android:sdk_toolchain_type for target platform @@internal_platforms_do_not_use//host:host
ToolchainResolution: No @@bazel_tools//tools/android:sdk_toolchain_type toolchain found for target platform @@internal_platforms_do_not_use//host:host.
ERROR: /root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/maven/BUILD:85:11: While resolving toolchains for target @@maven//:net_java_dev_jna_jna (43c96fe): No matching toolchains found for types @@bazel_tools//tools/android:sdk_toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@@bazel_tools//tools/android:sdk_toolchain_type'
BUILD
java_library(
name = "Loader",
srcs = ["Loader.java"],
runtime_deps = [":libjni_config_manger.so"],
deps = [
"@maven//:net_java_dev_jna_jna",
],
)
WORKSPACE
#################### java ####################
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
rules_java_dependencies()
rules_java_toolchains()
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()
load("@rules_android//:prereqs.bzl", "rules_android_prereqs")
rules_android_prereqs()
load("@rules_android//:defs.bzl", "rules_android_workspace")
rules_android_workspace()
load("@rules_android//rules:rules.bzl", "android_sdk_repository")
android_sdk_repository(
name = "androidsdk",
)
register_toolchains(
"@rules_android//toolchains/android:android_default_toolchain",
"@rules_android//toolchains/android_sdk:android_sdk_tools",
)
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
rules_jvm_external_setup()
JUNIT_PLATFORM_VERSION = "1.9.2"
JUNIT_JUPITER_VERSION = "5.9.2"
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
"net.java.dev.jna:jna:aar:5.13.0",
"com.google.truth:truth:0.32",
"org.junit.platform:junit-platform-launcher:%s" % JUNIT_PLATFORM_VERSION,
"org.junit.platform:junit-platform-reporting:%s" % JUNIT_PLATFORM_VERSION,
"org.junit.jupiter:junit-jupiter-api:%s" % JUNIT_JUPITER_VERSION,
"org.junit.jupiter:junit-jupiter-params:%s" % JUNIT_JUPITER_VERSION,
"org.junit.jupiter:junit-jupiter-engine:%s" % JUNIT_JUPITER_VERSION,
],
repositories = [
"https://maven.aliyun.com/repository/central",
],
)
load("@contrib_rules_jvm//:repositories.bzl", "contrib_rules_jvm_deps")
contrib_rules_jvm_deps()
load("@contrib_rules_jvm//:setup.bzl", "contrib_rules_jvm_setup")
contrib_rules_jvm_setup()
#################### hedron_compile_commands ####################
xiedeacc commented
.bazelrc
build --experimental_enable_android_migration_apis
build --experimental_google_legacy_api
xiedeacc commented
my mistake, change net.java.dev.jna:jna:aar:5.13.0", to net.java.dev.jna:jna:5.13.0", works