Nav*_*rab 0 android retrofit2 rx-java2
我在我的应用程序中使用 Retrofit 2 和 rxjava 2。这些是我的 gradle 实现:
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.4.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
Run Code Online (Sandbox Code Playgroud)
这是我的 API 连接类:
public class ApiConnection {
private static String BaseUrl = "http://mysites.com/";
private static Retrofit retrofit = null;
public static Retrofit getClient() {
Gson gson = new GsonBuilder()
.setLenient()
.create();
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(BaseUrl)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
}
return retrofit;
}
}
Run Code Online (Sandbox Code Playgroud)
我在这一行遇到错误:
RxJava2CallAdapterFactory
Run Code Online (Sandbox Code Playgroud)
这是错误:
Cannot resolve symbol 'RxJava2CallAdapterFactory
Run Code Online (Sandbox Code Playgroud)
我的代码有什么问题吗?
| 归档时间: |
|
| 查看次数: |
5764 次 |
| 最近记录: |