When I use Observable in my updated API on a phone with API 21, I got this error:
java.lang.NoClassDefFoundError: io.reactivex.Observable
but on the phone with API 19 or an emulator with API 23 it works.
This is my API:
import io.reactivex.Observable; import retrofit2.Response; import retrofit2.http.Body; import retrofit2.http.POST; public interface ApiService { @POST("/cp/api/") Observable<Response<Integer>> Get_BuyBox_Count(@Body Object request); }
and this is my Retrofit setting:
@Provides @Application_Scope @Store_Retrofit_Qualifier public Retrofit Store_retrofit(OkHttpClient client) { return new Retrofit.Builder() .baseUrl(Urls.Sotre_Base_Url) .client(client) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .addConverterFactory(JSONConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .build(); }
my dependencies:
compile 'com.squareup.retrofit2:retrofit:2.2.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'io.reactivex.rxjava2:rxjava:2.0.1' compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
source share