Questions tagged [protobuf-java]
289 questions
3
votes
1 answer
NoSuchMethod error on dealing with protobuf classes in a unit test
I'm trying to write unit tests of classes with using protobuf models and run them in Android Studio.
For example this is a simple converter test
class UpdateConfigConverterTest {
private val testable = UpdateConfigConverter()
@Test
…

Beloo
- 9,723
- 7
- 40
- 71
3
votes
0 answers
Generating non-final classes from Protobuf
I am using Protobuf in one of my Java projects and recently came across a use case that requires extending Protobuf generated class. From the documentation, it appears that the classes generated will always be immutable (Class generated with final…

Junaid
- 171
- 8
3
votes
1 answer
Clear fields in a ProtobufMessage Java
I have a proto message of the following form defined:
message A {
message B {
message C {
optional string details = 1;
optional string time = 2;
}
repeated C c = 1;
}
repeated B b =…

250
- 581
- 5
- 17
3
votes
1 answer
Is there any way to decompiler google protobuf binary file(.pb file) to .proto file
When I'm reversing an apk I got .pb file but not .proto file, is there any way to decompiler this file to .proto file or can I just generate java code from this .pb file ?

Kevin
- 87
- 2
- 9
3
votes
0 answers
Protoc import was not found or had errors
I have two simple .proto files. One has an import towards the other. When launching the command;
protocols --java_out = 'exit path' -I 'path root' 'path .proto with import'. It throws me the following error: Import "path proto2.proto" was not found…

dfuentes
- 31
- 4
3
votes
1 answer
Android Gradle Protobufs: How to compile the full protobuf and not the "lite" version?
Every example I can find of configuring build.gradle to compile protobufs uses the "lite" version and looks something like this:
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.6.0'
}
plugins {
javalite {
…

JamieB
- 703
- 1
- 6
- 17
3
votes
0 answers
protobuf plugin to enhance generated java class
I am looking for any example of using protobuf plugin architecture in practice.
Ultimately, I want to add custom annotations to generated java classes. But haven't gone far. I cannot quite understand how the insertion points…

Arash
- 11,697
- 14
- 54
- 81
3
votes
0 answers
protobuf-maven-plugin does not generate java artifacts
I have below maven configuration and I am not able to figure out why java artifacts are not generated for my proto. My Proto file is in folder
/src/main/proto/hello.proto
I see no errors in my console when I do
mvn package

Mahi G
- 391
- 1
- 7
- 16
3
votes
2 answers
Protobuf InvalidProtocolBufferException with some strings
We using protobuf v.3 to transfer messages from C# client to Java server over HTTP.
The message proto looks like this:
message CLIENT_MESSAGE {
string message = 1;
}
Both client and server uses UTF-8 character encoding for strings.
Everything…

NewJ
- 379
- 3
- 15
3
votes
1 answer
How to fix "com.google.protobuf.InvalidProtocolBufferException: Cannot find field" thrown from JsonFormat.parser().merge(...)?
I have 2 Protobuf models:
User:
package demo;
option java_package = "com.stackoverflow.question";
option java_outer_classname = "UserModel";
message User {
message UserHeader {
required int64 userId = 1;
}
required UserHeader…

Behrang
- 46,888
- 25
- 118
- 160
3
votes
2 answers
How to get value of protobuf custom option in Java?
Background: I'm writing a protoc plugin.
The custom protobuf option is implemented with the following:
syntax = "proto3";
package com.example.proto.options;
import "google/protobuf/descriptor.proto";
option java_multiple_files = true;
option…

Noel Yap
- 18,822
- 21
- 92
- 144
2
votes
0 answers
Protobuf (version3) optional field are not nullable in kotlin generated code
I don't understand why an optional field (like middle_name in the example bellow), is not nullable in the kotlin generated representation while in golang and rust is properly nullable (or optional).
syntax = "proto3";
message User{
string id =…

n3wtron
- 73
- 6
2
votes
0 answers
java spring boot with Protobuf is not working
I have the following application details, where I am adding protobuf to an existing spring boot application.
pom.xml dependencies
com.google.protobuf
protobuf-java
…

Saran
- 99
- 2
- 14
2
votes
1 answer
how to parse only one field from protobuf Serialize byte array
I need only one field from protobuf serialize byte array, but must call parseFrom function, which is low performance. how can I get field offset from byte array, and parse value by offset.

Chronos
- 69
- 3
2
votes
1 answer
How do I pass option to JavaPluginExtension using Kotlin DSL
I'm having issue converting these gradle groovy code to kotlin dsl.
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.8.0'
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option…

Riajul
- 1,140
- 15
- 20