- 前两天在RN项目中集成原生的firebase,之后报错插件版本冲突,报错信息如下:
What went wrong:
Execution failed for task ‘:app:preDebugBuild’.
Android dependency ‘com.google.android.gms:play-services-basement’ has different version for the compile (16.0.1) and runtime (16.1.0) classpath. You should manually set the same version via DependencyResolution
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
###尝试
- 这个问题可是折磨了我大半天,按照网上搜索的解决方式各种尝试
1. 方法一:
- 在项目的build.gradle中加入
allprojects {
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "16.1.0"
}
}
}
}
}
2. 方法二:
classpath 'com.google.gms:google-services:4.0.2' // Just updated the version here.
3. 方法三:
- 各个module的dependencies里的compile改为implementation
然而,并没有什么卵用
解决方法
- 之后静下心来好好思考了下,依赖版本冲突,肯定是存在重复依赖的问题。从这个思路着手:
第一步:
- 将firebase的依赖版本更新到最新版,这样能尽可能的降低版本冲突的概率;
参考firebase插件的各个发布版本
https://firebase.google.com/support/release-notes/android#20180523
第二步:
- 去除依赖冲突 参考 https://blog.csdn.net/yyo201/article/details/80570741
在Teminal 里面输入 gradlew app:dependencies 回车之后等一会儿就可以查看到整个项目的依赖树结构了。