0

Есть интерфейс

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

который вызывается в MainActivity со следующей конфирурацией

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
    ).cache();

    subscription = call_observable.subscribe(subscriber);

В файле зависимостей следующее

 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'

}

и после всего этого вылетает исключение

 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)"                               
3
  • Попробуйте так: Retrofit retrofit_weather = new Retrofit.Builder(). addCallAdapterFactory(RxJavaCallAdapterFactory.create()). addConverterFactory(GsonConverterFactory.create()). baseUrl(BASE_URL). build(); 3 дек 2015 в 15:20
  • к сожалению не работает, но появилась другая ошибка FATAL EXCEPTION: main Process: com.example.alex.weatherclient, PID: 2379 java.lang.AbstractMethodError: abstract method not implemented at retrofit.RxJavaCallAdapterFactory.get(RxJavaCallAdapterFactory.java)
    – Oleksandr
    3 дек 2015 в 15:34
  • Попробуйте обновить зависимости в gradle и не применяйте изменения в комментарие выше: compile 'com.squareup.retrofit:converter-simplexml:2.0.0-beta2' compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2' 3 дек 2015 в 21:36

1 ответ 1

1

Попробуйте изменить compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1' на compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'

1
  • собственно столкнулся с такой же проблемой, это мне помогло
    – VeteR_OK
    6 дек 2015 в 19:12

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими пользовательским соглашением, политикой конфиденциальности и политикой о куки

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.