Android dependency has different version.You should manually set the same version via DependencyReso

╰+哭是因爲堅強的太久メ 2022-05-15 08:00 237阅读 0赞

有时候导入一些module时,会出现以下问题

  1. Android dependency 'com.android.support:support-v4' has different version for the compile (23.3.0) and runtime (25.4.0) classpath. You should manually set the same version via DependencyResolution

这是因为module中可能依赖了不同的支持库,版本不一样。

解决办法
在项目根目录的build.gradle中加入以下代码
将details.useVersion后的值替换为统一的版本.

  1. subprojects {
  2. project.configurations.all {
  3. resolutionStrategy.eachDependency { details ->
  4. if (details.requested.group == 'com.android.support'
  5. && !details.requested.name.contains('multidex') ) {
  6. //统一版本号
  7. details.useVersion "25.4.0"
  8. }
  9. }
  10. }
  11. }

推荐方式
版本号使用非硬编码。
版本号由根build.gradle中ext定义的变量引用版本号。

发表评论

表情:
评论列表 (有 0 条评论,237人围观)

还没有评论,来说两句吧...

相关阅读