-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
As the title states, attempting to use android_local_test macro in a WORKSPACE based repository with a higher version than protobuf-java 4.29.3 will result in a build failure due to protobuf's recently introduced poison pill mechanism.
Is there a way to force rules_android to use a specific protobuf version?
Repro (note the 4.31.0 version brought in via http_archive):
WORKSPACE
workspace(name = "proto_transitive_failure")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_google_protobuf",
sha256 = "2b695cb1eaef8e173f884235ee6d55f57186e95d89ebb31361ee55cb5fd1b996",
strip_prefix = "protobuf-31.0",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v31.0.tar.gz"],
)
http_archive(
name = "rules_android",
sha256 = "4135e2fa37a94bb36c7801e33faef2934c9fe4f9a84d0035eacc4154c2c30e44",
strip_prefix = "rules_android-0.6.4",
url = "https://github.com/bazelbuild/rules_android/releases/download/v0.6.4/rules_android-v0.6.4.tar.gz",
)
load("@rules_android//:prereqs.bzl", "rules_android_prereqs")
rules_android_prereqs()
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
rules_java_dependencies()
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
load("@rules_java//java:repositories.bzl", "rules_java_toolchains")
rules_java_toolchains()
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
rules_jvm_external_setup()
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",
)
Result of bazel build {android_local_test target}:
INFO: Analyzed target //swh:android_lib (0 packages loaded, 0 targets configured).
ERROR: /Users/sokwhan/SourceCode/bazel-playground/swh/BUILD:7:19: Packaging Android Resources in @//swh:android_lib failed: (Exit 1): java failed: error executing PackageAndroidResources command (from target //swh:android_lib) external/remotejdk11_macos_aarch64/bin/java -Xms3G -Xmx3G -XX:+ExitOnOutOfMemoryError -jar ... (remaining 28 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.google.devtools.build.android.AndroidDataSerializer.flushTo(AndroidDataSerializer.java:71)
at com.google.devtools.build.android.AndroidResourceMerger.mergeDataToSymbols(AndroidResourceMerger.java:59)
at com.google.devtools.build.android.Aapt2ResourcePackagingAction.main(Aapt2ResourcePackagingAction.java:323)
at com.google.devtools.build.android.ResourceProcessorBusyBox$Tool$8.call(ResourceProcessorBusyBox.java:110)
at com.google.devtools.build.android.ResourceProcessorBusyBox.processRequest(ResourceProcessorBusyBox.java:238)
at com.google.devtools.build.android.ResourceProcessorBusyBox.main(ResourceProcessorBusyBox.java:175)
Caused by: com.google.protobuf.RuntimeVersion$ProtobufRuntimeVersionException: Detected incompatible Protobuf Gencode/Runtime versions when loading com.google.devtools.build.android.proto.SerializeFormat$Header: gencode 4.31.0, runtime 4.29.3. Runtime version cannot be older than the linked gencode version.
at com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersionImpl(RuntimeVersion.java:117)
at com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(RuntimeVersion.java:71)
at com.google.devtools.build.android.proto.SerializeFormat$Header.<clinit>(SerializeFormat.java:87)
... 6 more
(Full repro branch: https://github.com/l46kok/bazel-playground/tree/rules_android_transitive_protobuf)
Metadata
Metadata
Assignees
Labels
No labels