public class ApiService {
private static OkHttpClient okHttpClient = new OkHttpClient.Builder().
addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
.build();
private static Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://japi.juhe.cn/")
.client(okHttpClient)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
private ApiService(){
}
public static <T> T createApi(Class<T> clazz) {
return retrofit.create(clazz);
}
}
public interface Api {
@GET("joke/content/text.from")
Observable<JokeBean> getJokeBean(@Query("page") int page, @Query("pagesize") int pagesize, @Query("key") String key);
}
出现了上述问题,RxloScheduler-2这个问题,也就是NetWorkerOnMain,检查
compile 'com.squareup.retrofit2:retrofit:2.0.1'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.0.1'
compile 'com.google.code.gson:gson:2.6.2'
//rxjava
compile 'io.reactivex:rxjava:1.1.2'
compile 'io.reactivex:rxandroid:1.1.0'
//okhttp
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
最后改成这样就可以了,必须是rxjava跟retrofit的版本能兼容还是怎么回事,反正改完就可以了。