有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法为io创建调用适配器。reactivex。可观测的仍然有误差

我有一个类需要通过发送激活码来激活一个应用程序。但我总是犯这个错误。 “无法为io.reactivex.Observable创建调用适配器” 我跟踪了这个链接上的所有依赖项Unable to create call adapter for io.reactivex.Observable但错误仍然是一样的。请帮忙。 顺便说一句,这是我的代码

激活。爪哇

 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);

}

养蜂人

public interface HandlerAPI {
@GET("/authenticateapp/getcode")
Observable<AuthenticateModel> authApp(@Query("code") String activationCode);
}

AuthenticateModel。爪哇

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;
}
}

服务生成器。爪哇

 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);
}

建造。格拉德尔

compile 'io.reactivex.rxjava2:rx安卓: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'

共 (0) 个答案