Retrofit2.0与RxJava2.0结合出现的问题解决

来源:互联网 发布:淘宝客服外包多少钱 编辑:程序博客网 时间:2024/06/06 07:11
首先添加正确的依赖:
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    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'
Retrofit2.0的原依赖是:
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'

不支持RxJava2.0,所以引用会出现Observable相关adapter的错误,以及Rxjava2.0与1.0的依赖冲突问题,改掉一切都好。

实际应用网上很多,我就不说了,因为大神都说的很详细了,哈哈