Unable to create call adapter for io.reactivex.Observable

前端 未结 3 778
别那么骄傲
别那么骄傲 2020-12-25 09:12

I\'m going to send a simple get method to my server(it is Rails app) and get the result using RxJava and Retrofit. The thing that I did is:

My interface:



        
3条回答
  •  一整个雨季
    2020-12-25 09:58

    I ran into the same issue. Instead of adding new repositories you can add the dependency of Jake Wharton's library:

    implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    

    Then you can add factory:

    Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("https://api.example.com")
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .build();
    

    The fact that adapter has version 2.. does not mean that it is intended for use with RxJava 2, as I thought.

    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.1.0'
    

提交回复
热议问题