retrofit配合使用protobuf3
2017-04-19 09:09
1151 查看
之前项目中使用了retrofit网络请求框架和protobuf2的数据结构。因为protobuf3出来也有一段时间了,所以准备在新项目中换成protobuf3,但是在如果还是使用以前的那些库会导致编译出来的proto文件全部报错以及retrofit的converter-protobuf无法解析服务端返回的数据,下面给出proto2时候的需要的包,以及proto3时候需要的包。
protobuf2:
protobuf3:
要注意,'com.squareup.retrofit2:converter-protobuf'这个库的版本如果是2.1.0或者一下的话是解析不出来protobuf3的数据结构的,converter中用了反射的方法去获取字段的,proto2和proto3是不一样的,所以需要升级到最新的'com.squareup.retrofit2:converter-protobuf:2.2.0'
protobuf2:
compile 'com.squareup.retrofit2:converter-protobuf:2.1.0' compile 'com.google.protobuf:protobuf-java:2.6.1'
protobuf3:
compile 'com.squareup.retrofit2:converter-protobuf:2.2.0' compile 'com.google.protobuf:protobuf-java:3.2.0'
要注意,'com.squareup.retrofit2:converter-protobuf'这个库的版本如果是2.1.0或者一下的话是解析不出来protobuf3的数据结构的,converter中用了反射的方法去获取字段的,proto2和proto3是不一样的,所以需要升级到最新的'com.squareup.retrofit2:converter-protobuf:2.2.0'
相关文章推荐
- iOS中protobuf和tcp长链接(AsyncSocket)scoket配合使用
- 白鹭egret配合protobufjs的使用
- Android上GTalk以及Push机制的XMPP数据选择使用protobuf格式而非XML格式
- [转]Android上GTalk以及Push机制的XMPP数据选择使用protobuf格式而非XML格式
- Google protobuf的安装及使用
- java中使用Protobuf的实例(Demo)
- Google Protobuf 使用介绍
- 如何在Linux环境下在CodeBlock中安装使用Google Protobuf
- 基于netty的项目中使用protobuf,巧妙定义proto完成不同消息的编码和解码处理
- linux下Google的Protobuf安装及使用笔记
- Java protobuf框架使用向导
- Google protobuf 协议的使用
- google protobuf 使用心德
- 使用protobuf定义消息
- Google Protobuf 使用介绍
- Beetle使用Protobuf.net进行对象序列化传输
- google protobuf java 简单使用
- protobuf使用初步
- windows下面编译protobuf,生成.a文件供android NDK使用
- Java protobuf框架使用向导