Problem
When the Bazel module graph resolves protobuf to any version newer than 33.4 (e.g., 34.0, 35.0, etc.) via MVS, the ResourceProcessorBusyBox tool fails at runtime with a ProtobufRuntimeVersionException:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.google.devtools.build.android.DataResourceXml$1.<clinit>(DataResourceXml.java:199)
...
Caused by: com.google.protobuf.RuntimeVersion$ProtobufRuntimeVersionException:
Detected incompatible Protobuf Gencode/Runtime versions when loading XmlType:
gencode 4.34.0, runtime 4.33.4. Runtime version cannot be older than the linked gencode version.
at com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersionImpl(RuntimeVersion.java:153)
at com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(RuntimeVersion.java:72)
at com.google.devtools.build.android.proto.SerializeFormat$DataValueXml$XmlType.<clinit>(SerializeFormat.java:4134)
Root Cause
rules_android declares bazel_dep(name = "protobuf", version = "33.4") in its MODULE.bazel, and hardcodes com.google.protobuf:protobuf-java:4.33.4 in both its rules_android_maven and android_ide_common_30_1_3 Maven installs.
However, the serialize_format_java_pb target in //src/tools/java/com/google/devtools/build/android/proto is compiled using @com_google_protobuf//bazel:java_proto_library.bzl, which uses whatever version of protobuf the module graph ultimately resolves to via MVS. Since rules_android does not control the final resolved version, any other module in the graph that requires protobuf > 33.4 will trigger this failure.
This creates a mismatch:
- Proto compiler (gencode): Uses the MVS-resolved protobuf version (e.g.,
34.0, 35.0, etc.) → generates Java code stamped with that version
- Runtime jar:
@rules_android_maven//:com_google_protobuf_protobuf_java is pinned to 4.33.4
Since protobuf enforces runtime >= gencode, the tool crashes whenever the resolved protobuf module is newer than 33.4.
Affected Targets
Any aar_import or Android resource merging action that invokes ResourceProcessorBusyBox.
Reproduction
This will occur whenever any module in the dependency graph transitively requires protobuf > 33.4. This is increasingly common as many BCR modules have already updated their protobuf dependency. Examples of modules that pull in protobuf@34.0:
Suggested Fix
Bump the bazel_dep for protobuf and the corresponding protobuf-java / protobuf-java-util Maven pins in rules_android's MODULE.bazel to a current version (e.g., 34.0 / 4.34.0).
Workaround
Users can work around this by using single_version_override on protobuf, but this has chances of breaking other libraries that depend on the newer version.
Environment
- Bazel 9.1.0
rules_android 0.7.2
protobuf resolved to 34.0.bcr.1 via MVS (any version > 33.4 triggers the issue)
Problem
When the Bazel module graph resolves
protobufto any version newer than33.4(e.g.,34.0,35.0, etc.) via MVS, theResourceProcessorBusyBoxtool fails at runtime with aProtobufRuntimeVersionException:Root Cause
rules_androiddeclaresbazel_dep(name = "protobuf", version = "33.4")in itsMODULE.bazel, and hardcodescom.google.protobuf:protobuf-java:4.33.4in both itsrules_android_mavenandandroid_ide_common_30_1_3Maven installs.However, the
serialize_format_java_pbtarget in//src/tools/java/com/google/devtools/build/android/protois compiled using@com_google_protobuf//bazel:java_proto_library.bzl, which uses whatever version of protobuf the module graph ultimately resolves to via MVS. Sincerules_androiddoes not control the final resolved version, any other module in the graph that requires protobuf > 33.4 will trigger this failure.This creates a mismatch:
34.0,35.0, etc.) → generates Java code stamped with that version@rules_android_maven//:com_google_protobuf_protobuf_javais pinned to4.33.4Since protobuf enforces
runtime >= gencode, the tool crashes whenever the resolved protobuf module is newer than 33.4.Affected Targets
Any
aar_importor Android resource merging action that invokesResourceProcessorBusyBox.Reproduction
This will occur whenever any module in the dependency graph transitively requires
protobuf > 33.4. This is increasingly common as many BCR modules have already updated their protobuf dependency. Examples of modules that pull inprotobuf@34.0:rules_swift@3.5.0Suggested Fix
Bump the
bazel_depfor protobuf and the correspondingprotobuf-java/protobuf-java-utilMaven pins inrules_android'sMODULE.bazelto a current version (e.g.,34.0/4.34.0).Workaround
Users can work around this by using
single_version_overrideonprotobuf, but this has chances of breaking other libraries that depend on the newer version.Environment
rules_android0.7.2protobufresolved to34.0.bcr.1via MVS (any version > 33.4 triggers the issue)