1.前几天添加了最新版本号为2.1.14-RC1的RxJava的依赖
2.今天去添加Rx生命周期的依赖库
3.添加完点击Sync Now,出现如下错误提示:
Error:Execution failed for task ':app:preDebugBuild'.
> Android dependency 'io.reactivex.rxjava2:rxandroid' has different version for the compile (2.0.1) and runtime (2.0.2) classpath. You should manually set the same version via DependencyResolution(和下图报错显示一致哈)
4.在网上搜了好几种方式,都试了下,无果..
第一种尝试:
添加 subprojects 下面的代码块到project的build.gradle 文件,再Clean and Build again,我没有成功,报错依旧..
allprojects {
repositories {
//...
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "25.4.0"
}
}
}
}
}
第二种尝试:
包重复,剔除即可.然而我并没有在我的项目中找到重复的..
......
最后的解决方法:
Github上看RxJava的版本号,由几天前的2.1.14-RC1改为了2.1.14,ok,将项目中的版本号修改如下图,再Sync Now,报错就不见了!!
??我的疑问??
后来不明所以的我又用清奇的脑回路把版本号换回了2.1.14-RC1,Sync Now之后,又不报错了!!现在无论使用2.1.14还是2.1.14-RC1都是正常的,Why?!
哪位大神知道原因,请指点下,谢谢!