当我在带有API 21的电话中使用可观察到的API时,我得到了以下错误:
java.lang.NoClassDefFoundError: io.reactivex.Observable
但是在带有API 19的手机上,或者在带有API 23的模拟器上,它都能工作。
这是我的API接口:
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);
}
这是我的改造设置:
@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();
}
我的亲信:
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'
发布于 2017-07-09 13:10:15
终于,过了一会儿,我找到了解决办法。
这个问题是Rxjava和Constrainlayout冲突的。
compile 'com.android.support.constraint:constraint-layout:1.0.2'
使用
compile 'io.reactivex:rxjava:1.2.6'
https://stackoverflow.com/questions/44300482
复制相似问题