If you get build errors like these when using protobufs with java, look below.
The method getOptions() from the type Descriptors.Descriptor refers to the missing type MessageOptions
The import com.google.protobuf.DescriptorProtos cannot be resolved
FileDescriptorProto cannot be resolved to a type
Ok, the so-called Java tutorial for protobufs doesn’t actually mention how to get the protobuf library into your project. It implies that all the code is in your single generated .java file, which would actually be pretty nice, but that isn’t case.
Look at the source and you will see references to
com.google.protobuf, which you can find in thejava/src/main/javadirectory in the protobuf source. Copy that into your project however, and it will have build errors.The solution is in the
README.txtfile. Yeah, maybe I should have read it, but shouldn’t all the information you need to get started be in the getting started tutorial? Anyway, do this:And then copy the java files into your project.