【问题标题】:Android dependency 'io.reactivex.rxjava2:rxandroid' has different versionAndroid 依赖 'io.reactivex.rxjava2:rxandroid' 有不同的版本
【发布时间】:2018-11-15 11:43:22
【问题描述】:

将项目与 gradle 文件同步时,Android Studio 显示此错误:

Android dependency 'io.reactivex.rxjava2:rxandroid' has different version for the compile (2.0.1) and runtime (2.1.0) classpath. You should manually set the same version via DependencyResolution

我已经尝试解决它:

resolutionStrategy.force 'io.reactivex.rxjava2:rxandroid:2.1.0'

但结果相同。

当我在库定义中将 'compile' 更改为 'implementation' 时会出现此问题

这就是我定义其余 rx 库的方式:

buildscript {

    ext.retrofitVersion = '2.4.0'
    ext.rxVersion = '2.2.1'
    ext.rxAndroidVersion = '2.1.0'
    ext.okhttpVersion = '3.8.1'
    ext.rxKotlinVersion = '2.0.0'

    ...


    repositories {
        mavenCentral()
        jcenter()
    }

}
//Rx & Retrofit 2 **********************************
implementation("com.squareup.retrofit2:retrofit:$retrofitVersion") {
    // exclude Retrofit’s OkHttp peer-dependency module and define your own module import
    exclude module: 'okhttp'
}
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
implementation "io.reactivex.rxjava2:rxkotlin:$rxKotlinVersion"
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
implementation "io.reactivex.rxjava2:rxandroid:${rxAndroidVersion}"
implementation "io.reactivex.rxjava2:rxjava:$rxVersion"

有什么办法可以解决这个问题吗?

【问题讨论】:

    标签: android build.gradle rx-android resolutionstrategy


    【解决方案1】:

    好的,最后我按照@yayo-arellano solution 解决了这个问题。我打算用“api”替换“实现”。

    【讨论】:

      猜你喜欢
      • 2018-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-16
      • 2017-09-13
      • 2019-12-25
      • 2017-11-23
      • 1970-01-01
      相关资源
      最近更新 更多