我正在努力解决这个问题。当使用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'
但结果相同。
当我在库定义中将“编译”更改为“实现”时,会发生此问题
这是我定义其余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"
有什么主意我该如何解决这个问题?
谢谢。