Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Protobuf gencode/runtime version mismatch in ResourceProcessorBusyBox when protobuf module resolves to any version > 33.4 #498

Open

Description

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.DataResourceXml1ドル.<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:

  • rules_swift@3.5.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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /