square / retrofit

A type-safe HTTP client for Android and the JVM
https://square.github.io/retrofit/
Apache License 2.0
43.04k stars 7.3k forks source link

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

Closed raghunandankavi2010 closed 8 years ago

raghunandankavi2010 commented 8 years ago

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.

JakeWharton commented 8 years ago

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 notifications@github.com 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 .

raghunandankavi2010 commented 8 years ago

Thank you. I missed that.

longnguyencse commented 7 years ago

Thanks you

KDisEDDY commented 7 years ago

kiang kiang kiang

effectivecui commented 7 years ago

New Solution:

https://github.com/square/retrofit/tree/master/retrofit-adapters/rxjava2

yancechen commented 7 years ago

Thanks you

fuchangle commented 6 years ago

thanks