Questions tagged [protobuf-java]
289 questions
4
votes
2 answers
gRPC client: error in compiled file (io.grpc.protobuf does not exist)
I made a simple protobuf+gRPC server/client example with Python, and wanted now to complete it with an Android Java client. However, I struggled through the documentation and got it mostly working (.proto compiles in Android Studio), BUT now I get…

André
- 142
- 1
- 15
4
votes
2 answers
Java class generated from protobuf has compilation errors
I'm trying to generated java classes from protobuf.
Below is my protobuf -
syntax = "proto2";
package part2;
option java_package = "part2";
message OnlineStoreUser {
required int32 userid = 1;
required string username = 2;
optional…

user51
- 8,843
- 21
- 79
- 158
4
votes
1 answer
How to Access attributes from grpc Context.current()?
Would it be possible to access context attributes of a grpc call from the rpc method definition?
I have written a Server Interceptor which is something similar to this
@Override
public ServerCall.Listener…

chandan
- 964
- 1
- 19
- 26
4
votes
1 answer
Convert protobuf-lite message to JSON and back
When using the regular Java Protobuf, you can use JsonFormat from com.google.protobuf:protobuf-java-util to convert the Protobuf message to a JSON string, and back.
But does there exist a converter that works with Java Protobuf Lite? JsonFormat…

Rok Povsic
- 4,626
- 5
- 37
- 53
4
votes
1 answer
Writing a proto file for a JSON input containing random field names
A newbie to protobuff here. I am working on compressing a JSON file using protobuff. The problem is that this JSON file comes as a response from a webserver and contains certain fields whose name are random i.e. with each request posted to the…

PanDroid
- 41
- 1
- 3
4
votes
3 answers
How can I add my own code to JAVA generated classes from proto file?
I'm using protobuf and I'm generating JAVA classes from the following proto file.
syntax = "proto3";
enum Greeting {
NONE = 0;
MR = 1;
MRS = 2;
MISS = 3;
}
message Hello {
Greeting greeting = 1;
string name = 2;
}
message…

Alberto
- 63
- 1
- 8
3
votes
1 answer
Protobuf: to use same Message name with different packages
I am using protobuf java, with following .proto
// service1.proto
option java_package = "package";
option java_outer_classname = "Proto1";
message M {
... // some definition
}
and
// service2.proto
option java_package = "package";
option…

Litchy
- 623
- 7
- 23
3
votes
3 answers
Duplicate handling strategy error with gradle while using protobuf for java
I am using the below configuration build.gradle
plugins {
id "com.google.protobuf" version "0.8.17"
id "java"
}
group "de.prerna.aws.tests"
version "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
ext {
protobufVersion =…

coder25
- 2,363
- 12
- 57
- 104
3
votes
0 answers
Is there a way to use TreeBidiMap with a Comparator instead of implementing Comparable?
I am dealing with autogenerated protobuf classes as the value in my TreeBidiMap. That means that they cannot implement Comparable. But building a Comparator for them would be trivial. Is there an implementation for TreeBidiMap that works with…

David Schumann
- 13,380
- 9
- 75
- 96
3
votes
1 answer
Duplicate class error protobuf-java & protobuf-javalite with DialogFlow and Firebase
It basically happening because firebase firestore is using
protobuf-javalite and DialogFlow is using protobuf-java library and
they have large number of common classes. I tried different solution
but not able to solve it.
1. Excluding…

Vikas Rai
- 327
- 3
- 10
3
votes
0 answers
Once I added firebase dependency and got duplicated protobuf classes error
Everything is working fine once I added the below dependencies in the Gradle getting the below error
dependency :
implementation 'com.google.firebase:firebase-perf:19.1.0'
Error:
Duplicate class com.google.protobuf.AbstractMessageLite found…

Mahi
- 1,754
- 2
- 16
- 37
3
votes
0 answers
Protobuf 3 java: How to diff and update only those fields that are in input object? Scenario: e.g persistence to db
In the below code, the api gets a "Person" obj in POST body,
My technical requirement:
If only one field of Person is sent, only that field must be compared to object from db.
if there is a change, then call save() if not just return object from…

Espresso
- 5,378
- 4
- 35
- 66
3
votes
2 answers
How to log Protobuf string in nested objects in a human-readable way?
Given a proto file:
syntax = "proto3";
package hello;
message TopGreeting {
NestedGreeting greeting = 1;
}
message NestedGreeting {
Greeting greeting = 1;
}
message Greeting {
string message = 1;
}
and the code:
public class Main {
…

Abhijit Sarkar
- 21,927
- 20
- 110
- 219
3
votes
1 answer
grpc/protobuffer ask for specific fields
GraphQL lets you ask for specific fields, the response contains only the fields that you had asked for. For example:
a graphql query like:
{
hero {
name
}
}
will return:
{
"data": {
"hero": {
"name": "R2-D2"
}
}
}
where…

Sanath.usk
- 84
- 5
3
votes
2 answers
In a proto, how can I define a map as a custom option
In my proto file, I want to define a map as a custom option, tried a few things but none is working.
my metadata proto file:
syntax = "proto2";
import "google/protobuf/descriptor.proto";
package com.util;
option java_package = "com.util";
message…

JDev
- 1,662
- 4
- 25
- 55