JsonFormat.printer()。打印()不接受我的留言

时间:2019-02-01 17:46:13

标签: android protocol-buffers

我正在开发使用AndroidStudio一个应用程序,并且我使用的protobuf通过蓝牙低能量发送数据。
但是由于环境限制,我还需要能够在Json中表示此数据。
我发现JsonFormat可以胜任这项工作,但不幸的是我遇到了麻烦。
如果我想将JsonFormat.printer()。print()应用于我的Message之一,则该项目无法编译,并且该方法以红色加下划线:print(com.google.protobuf.MessageOrBuilder) in Printer cannot be applied to MyMessage
如果我通过生成器而不是消息,则会遇到相同的问题。
其他一切工作的顺利进行。
我的build.gradle包含

classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.7"
classpath 'com.google.protobuf:protobuf-java:3.4.0'
classpath 'com.google.protobuf:protoc:3.0.0'
classpath 'com.google.protobuf:protobuf-java-util:3.4.0'

implementation 'com.google.protobuf:protobuf-lite:3.0.0'
implementation 'com.google.protobuf:protoc:3.0.0'
implementation 'com.google.protobuf:protobuf-java:3.4.0'
implementation 'com.google.protobuf:protobuf-java-util:3.4.0'

有人对这个问题有任何想法吗?
谢谢

0 个答案:

没有答案