google / protobuf-gradle-plugin

Protobuf Plugin for Gradle
Other
1.76k stars 274 forks source link

Compilation of the generated code fails with protobuf 4.26.0 #752

Closed sergeykad closed 4 months ago

sergeykad commented 6 months ago

The generated code does not compile with protobuf 4.26.0.

 error: cannot find symbol
    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(operatorId_)) {
                                             ^
  symbol:   method isStringEmpty(Object)
  location: class GeneratedMessage
ejona86 commented 5 months ago

You are probably not using protoc 26. Protobuf 4.x is incompatible with the earlier generated code.

sergeykad commented 4 months ago

It is running with com.google.protobuf:protoc:4.26.0 That's the version that you meant, correct?

I am not sure if it's related, but others also experience compilation issues with the protobuf 4.x https://github.com/grpc/grpc-java/issues/11015

ejona86 commented 4 months ago

You need to match protobuf-java 4.26 with protoc 4.26. You can't use any 3.x generated code.

This is not a protobuf-gradle-plugin issue. This is just a protobuf issue.

I'm aware of the grpc issue. It's an ecosystem issue with protobuf. Protobuf will be releasing a new 3.x version that is more compatible with 4.x to ease upgrading. But all that is separate than this protobuf-gradle-plugin.