Android 网络库 Retrofit
Summary: Author: 张亚飞 | Read Time: 1 minute read | Published: 2018-04-17
Filed under
—
Categories:
Linux
—
Tags:
Note,
学习 Retrofit
文章
- 更上一层楼-Android研发工程师高级进阶
- Retrofit 解析 JSON 数据
- Retrofit 2.0: The biggest update yet on the best HTTP Client Library for Android
- Retrofit 2 — Upgrade Guide from 1.9
- Retrofit 开发示例
使用 Retrofit
以 Post
发送一个对象
- Retrofit — Send Objects in Request Body
- method POST must have a request body
- Retrofit: API Integration Made Easy
问题分析总结
出现错误
java.lang.IllegalArgumentException: Unable to create call adapter for rx.Observable<java.util.List<com.coam.model.test.GithubUser>>
需要将 rxjava
结合到 retrofit
,在构建请求客户端的地方加上 .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
如下:
Retrofit retrofit = new Retrofit.Builder().baseUrl(ENDPOINT)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
//mService = retrofit.create(GithubAPIInterface.class);
return new GithubService(retrofit.create(GithubAPIInterface.class));
并在 dependencies
中引入
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
Comments