Android 依赖项 'io.reactivex.rxjava2:rxandroid' 有不同的版本
Android dependency 'io.reactivex.rxjava2:rxandroid' has different version
当项目与 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"
有什么办法可以解决这个问题吗?
好的,我终于解决了@yayo-arellano solution 的问题。我要用 "api" 替换 "implementation"。
当项目与 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"
有什么办法可以解决这个问题吗?
好的,我终于解决了@yayo-arellano solution 的问题。我要用 "api" 替换 "implementation"。