When I use Observable in my retrofit API on the phone with API 21 I got this error:
java.lang.NoClassDefFoundError: io.reactivex.Observable
but on the phone with API 19 or emulator with API 23 it works.
This is my API Interface:
import io.reactivex.Observable;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.POST;
public interface ApiService {
/**
* Created by Mohsen on 5/10/2017.
*
*/
@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'
Finally, after while I found the solution.
the problem is conflicting Rxjava with Constrainlayout
compile 'com.android.support.constraint:constraint-layout:1.0.2'
with
compile 'io.reactivex:rxjava:1.2.6'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With