I've been using protobuf to generate intra-backend messages but when I moved to a new laptop and set up protoc again it seems it doesn't generate working java code anymore.
I'm on the latest Ubuntu 16.04 and have downloaded the latest protoc
$ protoc --version
libprotoc 3.5.1
Building it, without errors or warnings, with
protoc --java_out=<javapath> --python_out=<pythonpath> messages.proto
The messages shown by Eclipse / maven are these:
The method parseUnknownFieldProto3(CodedInputStream, UnknownFieldSet.Builder, ExtensionRegistryLite, int) is undefined for the type MessageA.Request Messages.java ...path, line etc...
snip, more of the same for other messages
Messages.Shutdown Messages.java ...path...
The method setUnknownFieldsProto3(UnknownFieldSet) is undefined for the type GeneratedMessageV3.Builder<Messages.Request.Builder> Messages.java ...path, line etc...
snip, more of the same
If I manually rename parseUnknownFieldProtoc3
to parseUnknownField
and same for SetUnknownFields the error goes away but that feels like the wrong solution.
What am I missing?
The protocol buffer compiler produces Java output when invoked with the --java_out= command-line flag. The parameter to the --java_out= option is the directory where you want the compiler to write your Java output. For each . proto file input, the compiler creates a wrapper .
proto file are simple: you add a message for each data structure you want to serialize, then specify a name and a type for each field in the message. Here is the . proto file that defines your messages, addressbook. proto .
proto files), the code that the proto compiler generates to interface with data, language-specific runtime libraries, and the serialization format for data that is written to a file (or sent across a network connection).
protoc is a compiler for protocol buffers definitions files. It can can generate C++, Java and Python source code for the classes defined in PROTO_FILE.
It sounds like you're using mismatched generated code and library code. If you're using protoc
3.5.1 you need the library code from 3.5.1; alternatively, if you're using library 3.3.0 - you need the protoc
from 3.3.0.
All the releases are here, with 3.5.1 and 3.3.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With