RxJavaCallAdapterFactory 无法转换为 Factory [英] RxJavaCallAdapterFactory cannot be converted to Factory
问题描述
我正在尝试按照本指南中的指南使用 Retrofit 2 和 RxJavahttps://inthecheesefactory.com/blog/retrofit-2.0/en
I'm trying to use Retrofit 2 and RxJava following the guide in this https://inthecheesefactory.com/blog/retrofit-2.0/en
在RxJava 与 CallAdapter 集成"部分" 解释了如何使用 RxJava 进行改造
In section "RxJava Integration with CallAdapter " explains how use RxJava with retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.nuuneoi.com/base/")
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
但是在编译过程中出现如下错误:
However during compilation there is the following error:
Error:(63, 71) error: incompatible types: RxJavaCallAdapterFactory cannot be converted to Factory
我该如何解决?谢谢
推荐答案
确保您对主要 Retrofit 依赖项、Gson 转换器依赖项和 RxJava 适配器依赖项使用相同的 groupId 和版本.
Make sure you are using the same groupId and version for the main Retrofit dependency, the Gson converter dependency, and the RxJava adapter dependency.
我猜你的看起来像这样:
I'm guessing yours look something like this:
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
(注意它们使用不同的 groupId 和版本号)
(Note that they use different groupIds and version numbers)
它们应该看起来都一样:
They should all look the same like this:
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
这篇关于RxJavaCallAdapterFactory 无法转换为 Factory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!