I suspect that your code is getting an error because it's trying to parse a
.proto file as a serialized protocol buffer. (This won't work since .proto
files use a text representation very different from the standard protobuf
binary format.) Probably the best way to fix this problem would be to
invoke protoc with --descriptor_set_out to parse the proto file and convert
it into a serialized FileDescriptorSet. A FileDescriptorSet is just a
protocol buffer, so once you have it in that form you can easily parse it
like you would parse any other serialized proto.

On Thu, Feb 23, 2023 at 4:59 PM ritesh singh <riteshdvp...@gmail.com> wrote:

> Hello,
>
> I am working on creating a Android Studio plugin for proto data store.
> Android uses proto-lite, my current approach, i get the .pb file and
> .proto file and use the same in intellij plugin to deserialise it.
>
>
>
>
>
>
>
>
>
>
>
>
> *val psiFile = PsiManager.getInstance(project).findFile(protoFile) val
> protoFileContent = psiFile!!.text val fileDescriptorProto:
> DescriptorProtos.FileDescriptorProto =
> DescriptorProtos.FileDescriptorProto.parseFrom(protoFileContent.byteInputStream())
> val fileDescriptor =
> Descriptors.FileDescriptor.buildFrom(fileDescriptorProto, arrayOfNulls(0))
> val messageDescriptor = fileDescriptor.messageTypes[0] val buffer =
> pbFile.contentsToByteArray() val messageBuilder: DynamicMessage.Builder =
> DynamicMessage.newBuilder(messageDescriptor)
> messageBuilder.mergeFrom(buffer) val message = messageBuilder.build() val
> text: String = TextFormat.printToString(message)*
>
> Above code is throwing error in parsing step,* Protocol message tag had
> invalid wire type.*
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/7fe3a019-e846-4792-8d8a-1655a2d93975n%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/7fe3a019-e846-4792-8d8a-1655a2d93975n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr7uOTgCL-8Qf7UTZaekpNjo1A%2BgOT_c2-6yQnssfkQGNQ%40mail.gmail.com.

Reply via email to