Error:Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:recyclerview-v7' has different version for the compile (25.3.1) and runtime (25.4.0) classpath. You should manually set the same version via DependencyResolution
最外层项目的build.gradle {新增:三方库指定版本}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
//统一版本号
details.useVersion "25.3.1"
}
if(details.requested.group == 'com.google.code.gson'&&details.requested.name.startsWith("gson"))
{
details.useVersion "2.7"
}
}
}
}
本文详细介绍了如何在Android项目中解决依赖库版本不一致的问题,通过在build.gradle文件中设置统一的版本号,确保编译和运行时使用相同的库版本,避免了因版本差异导致的错误。

被折叠的 条评论
为什么被折叠?



