这两天编译旧的项目,遇到了com.android.support:support包错误Android dependency has different version for the compile and runtime。项目包含多个module,太多依赖很是蛋疼,新版本AS打开使用旧版本AS+gradle插件创建的工程真是各种坑。搜索了半天,网上说的方法有的是挨个改module里面的依赖包版本,结果折腾了很久也无卵用。不知道是不是跟AS版本有关系,本人使用的是3.1.3版本。最终在万能的stackoverflow找到了解决办法。
最优的解决办法:
无视module,直接在工程的build.gradle中添加配置:
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion '25.1.0'//这个版本号设置为你想要的版本
}
}
}
}