coolchandrakumar
09/29/2020, 5:15 AMcom.google.protobuf.InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly in the middle of a field.
at com.google.protobuf.GeneratedMessageLite.parsePartialFrom(GeneratedMessageLite.java:1563)
Android Project
using protobuf lite plugincoolchandrakumar
09/29/2020, 5:16 AMtry {
//val stream = assets.open("JsonData.json")
val jsonString = "{\"platform\":\"chan\"}"
val chanData = ChanDataProto.ChanData.parseFrom(jsonString.encodeToByteArray())
Log.d("ChanLog", "Value: ${chanData.platform}")
} catch (ex: Exception) {
ex.printStackTrace()
}
Proto
syntax = "proto3";
package tutorial;
option java_package = "com.chan.chanprotobuf";
option java_outer_classname = "ChanDataProto";
message ChanData {
string platform = 1;
}
Json
{
"platform": "chan"
}