Retrofit: Caused by: java.lang.IllegalArgumentException: Could not locate call adapter for io.reactivex.Observable

Created on 25 Sep 2016  Â·  7Comments  Â·  Source: square/retrofit

My application was not building due to duplicates files in .apk as mentioned here

https://github.com/ReactiveX/RxJava/issues/4445

So adding this

 packagingOptions {
    exclude 'META-INF/rxjava.properties'
}

did not cause the problem again., but a new issue cropped up

 Caused by: java.lang.IllegalArgumentException: Could not locate calladapter for 
io.reactivex.Observable<myModelclass>.
                                Tried:
                                 * retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
                                 * retrofit2.ExecutorCallAdapterFactory
                                ....

I do have

@Headers({"Content-Type: application/json;charset=UTF-8"})
@GET(Constants.FETCH_FEED)
Observable<FeedResponse> fetch_Feed();

And then

  Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(Constants.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();
   Observable<myModelclass> response = retrofit.create(Api.class).fetch_Feed();

My build.gradle file

 compile 'com.squareup.okhttp3:okhttp:3.4.1'
 compile 'com.squareup.retrofit2:retrofit:2.1.0'
 compile 'io.reactivex.rxjava2:rxjava:2.0.0-RC3'
 compile 'io.reactivex.rxjava2:rxandroid:2.0.0-RC1'
 compile 'com.squareup.retrofit2:converter-gson:2.1.0'
 compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'

This could be related to RxJava2. This is not reproducible with version1. In which case issue should be opened in RxJava and this issue closed.

Most helpful comment

You need to use https://github.com/JakeWharton/retrofit2-rxjava2-adapter
for RxJava 2 not the built in adapter which only handles RxJava 1.

On Sun, Sep 25, 2016, 9:24 AM Raghunandan Kavi [email protected]
wrote:

My application was not building due to duplicates files in .apk as
mentioned here

ReactiveX/RxJava#4445 https://github.com/ReactiveX/RxJava/issues/4445

So adding this

packagingOptions {
exclude 'META-INF/rxjava.properties'
}

did not cause the problem again., but a new issue cropped up

Caused by: java.lang.IllegalArgumentException: Could not locate calladapter for
io.reactivex.Observable.
Tried:
* retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
* retrofit2.ExecutorCallAdapterFactory
....

I do have

Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
Observable response = retrofit.create(Api.class).fetch_Feed();

My build.gradle file

compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.0-RC3'
compile 'io.reactivex.rxjava2:rxandroid:2.0.0-RC1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/square/retrofit/issues/2028, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEYzP0HiDfYEXKr15ySySz_DZ0z7jks5qtnYngaJpZM4KF5qB
.

All 7 comments

You need to use https://github.com/JakeWharton/retrofit2-rxjava2-adapter
for RxJava 2 not the built in adapter which only handles RxJava 1.

On Sun, Sep 25, 2016, 9:24 AM Raghunandan Kavi [email protected]
wrote:

My application was not building due to duplicates files in .apk as
mentioned here

ReactiveX/RxJava#4445 https://github.com/ReactiveX/RxJava/issues/4445

So adding this

packagingOptions {
exclude 'META-INF/rxjava.properties'
}

did not cause the problem again., but a new issue cropped up

Caused by: java.lang.IllegalArgumentException: Could not locate calladapter for
io.reactivex.Observable.
Tried:
* retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
* retrofit2.ExecutorCallAdapterFactory
....

I do have

Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
Observable response = retrofit.create(Api.class).fetch_Feed();

My build.gradle file

compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.0-RC3'
compile 'io.reactivex.rxjava2:rxandroid:2.0.0-RC1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/square/retrofit/issues/2028, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEYzP0HiDfYEXKr15ySySz_DZ0z7jks5qtnYngaJpZM4KF5qB
.

Thank you. I missed that.

Thanks you

kiang kiang kiang

Thanks you

thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Liberuman picture Liberuman  Â·  3Comments

pankai picture pankai  Â·  3Comments

kkunsue picture kkunsue  Â·  3Comments

chriskessel picture chriskessel  Â·  3Comments

jpshelley picture jpshelley  Â·  4Comments