我正在尝试使用Retrofit 2和RxJava,遵循本https://inthecheesefactory.com/blog/retrofit-2.0/en中的指南
在"RxJava集成与CallAdapter“一节中,解释了如何使用RxJava进行改造
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.nuuneoi.com/base/")
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();但是,在编译过程中出现以下错误:
Error:(63, 71) error: incompatible types: RxJavaCallAdapterFactory cannot be converted to Factory我怎么才能修好它?谢谢
发布于 2016-06-09 18:05:38
确保您使用相同的groupId和版本来处理主Retrofit依赖项、Gson转换器依赖项和RxJava适配器依赖项。
我猜你的看起来像这样:
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'(请注意,它们使用不同的groupIds和版本号)
他们都应该是这样的:
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'发布于 2017-01-04 09:25:09
当前,添加“com.square up.regrefit:adapter:2.0.0”会出现以下错误
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties但是,相反,添加“编译'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0",使打包成功
发布于 2018-10-06 12:03:44
将修改后的rxjava适配器更改为
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"并将CallAdapterFactory更改为
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())它会看起来像这样
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();https://stackoverflow.com/questions/37727928
复制相似问题