Oleksandr
Oleksandr

Reputation: 13

RxAndroid with Retrofit 2.0

I have interface

 @GET("/data, 2.5/forecast/daily")
   Observable<MultilingualWeather> getWeatherByIdWithMultilingual(
    @Query("id") String id,
    @Query("lang") String lang,
    @Query("appid") String appid);

MainActivity be called up in the following configuration

 Retrofit retrofit_weather = new Retrofit.Builder().
        baseUrl(BASE_URL).
        addConverterFactory(GsonConverterFactory.create()).
        addCallAdapterFactory(RxJavaCallAdapterFactory.create()).
        build();

GetWeatherForLocation getWeather = retrofit_weather.create(GetWeatherForLocation.class);

Observable<MultilingualWeather> call_observable = getWeather.
            getWeatherByIdWithMultilingual(
            CITY_ID,
            LANG,
            KEY
    );

    subscription = call_observable.subscribe(subscriber);

The following file dependencies

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'io.reactivex:rxjava:1.0.16'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'

}

and after all this takes off exception

 FATAL EXCEPTION: main Process: com.example.alex.weatherclient, PID: 16658 java.lang.AbstractMethodError: abstract method "retrofit.CallAdapter retrofit.CallAdapter$Factory.get(java.lang.reflect.Type, java.lang.annotation.Annotation[], retrofit.Retrofit)"         

Upvotes: 1

Views: 928

Answers (2)

VeteR_OK
VeteR_OK

Reputation: 127

Replace in build.gradle

compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1' 

on

compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'

Upvotes: 5

EnduroDave
EnduroDave

Reputation: 1033

looks like a typo. Your interface uses getWeatherByIdWithMultilingual and your code uses getWeatherByIdWithMultilingual2

Upvotes: 0

Related Questions