I have a class that needs to activate an app by sending the activation code. But I always got this error. "Unable to create call adapter for io.reactivex.Observable" I followed all the dependecies on this link. Unable to create call adapter for io.reactivex.Observable but still the error is the same. Please help. BTW here's my code
Activate.java
private void activateApp(String activationCode) {
ServiceGenerator.changeApiBaseUrl(BASE_URL);
apiHandler = ServiceGenerator.createService(HandlerAPI.class);
Observable<AuthenticateModel> observable = a
apiHandler.authApp(activationCode)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread());
Observer<AuthenticateModel> observer = new Observer<AuthenticateModel>() {
@Override
public void onSubscribe(Disposable d) {
Log.d("AUTHENTICATE", d.toString());
}
@Override
public void onNext(AuthenticateModel authenticateModel) {
Log.d("AUTHENTICATE", authenticateModel.getAssignedTo());
Log.d("AUTHENTICATE", authenticateModel.getIsActive());
Log.d("AUTHENTICATE", authenticateModel.getUnlockerCode());
Log.d("AUTHENTICATE",
Integer.toString(authenticateModel.getAuthenticateId()));
}
@Override
public void onError(Throwable e) {
Log.d("AUTHENTICATE", e.getMessage().toString());
}
@Override
public void onComplete() {
Log.d("AUTHENTICATE", "FINISH");
}
};
observable.subscribe(observer);
}
APIHandler
public interface HandlerAPI {
@GET("/authenticateapp/getcode")
Observable<AuthenticateModel> authApp(@Query("code") String activationCode);
}
AuthenticateModel.java
public class AuthenticateModel {
private int authenticateId;
private String assignedTo;
private int idRDM;
private String isActive;
private String unlockerCode;
public AuthenticateModel() {
}
public AuthenticateModel(int authenticateId, String assignedTo, int idRDM,
String isActive, String unlockerCode) {
this.authenticateId = authenticateId;
this.assignedTo = assignedTo;
this.idRDM = idRDM;
this.isActive = isActive;
this.unlockerCode = unlockerCode;
}
public int getAuthenticateId() {
return authenticateId;
}
public void setAuthenticateId(int authenticateId) {
this.authenticateId = authenticateId;
}
public String getAssignedTo() {
return assignedTo;
}
public void setAssignedTo(String assignedTo) {
this.assignedTo = assignedTo;
}
public int getIdRDM() {
return idRDM;
}
public void setIdRDM(int idRDM) {
this.idRDM = idRDM;
}
public String getIsActive() {
return isActive;
}
public void setIsActive(String isActive) {
this.isActive = isActive;
}
public String getUnlockerCode() {
return unlockerCode;
}
public void setUnlockerCode(String unlockerCode) {
this.unlockerCode = unlockerCode;
}
}
ServiceGenerator.java
private static Retrofit.Builder builder =
new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
// <- add this
.baseUrl(apiBaseUrl)
.client(getRequestHeader());
public static <S> S createService(
Class<S> serviceClass) {
httpClient.addInterceptor(logging);
builder.client(httpClient.build());
retrofit = builder.build();
return retrofit.create(serviceClass);
}
build.gradle
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.1.5'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'