51.Rxjava+RxAndroid+Retrofit组合问题

时间:2022-07-14 17:46:08

51.Rxjava+RxAndroid+Retrofit组合问题

1.Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for rx.Observable

fix :

compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'

this.retrofit = new Retrofit.Builder()
        .baseUrl(GankApi.BASE_URL)
        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
        .addConverterFactory(GsonConverterFactory.create(this.gson))
        .client(okHttpClient)
        .build();

2.retrofit.HttpException: HTTP 404 Not Found

**fix : **retrofit2.0后:BaseUrl要以/结尾,@GET 等请求不要以/开头。


3.java.lang.AbstractMethodError: abstract method “retrofit.CallAdapter retrofit.CallAdapter$Factory.get

fix : 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
换为'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'