Reputation: 1787
I'm using retrofit 2 and rxjava 2 in my application. These are my gradle implementations:
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'
This is my API connection class:
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;
}
}
I got an error on this line :
RxJava2CallAdapterFactory
This is the error:
Cannot resolve symbol 'RxJava2CallAdapterFactory
What is wrong with my code?
Upvotes: 0
Views: 6356
Reputation: 4332
The correct import is implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0"
(note the use of rxjava2)
Upvotes: 6