原文:https://www.jianshu.com/p/0fe985a7e17e

项目中不同Module的support包版本冲突怎么办?

只需要将以下代码复制到每个模块的build.gradle(Module:xxx)文件的根目录即可:

// 统一当前Module的所有support包版本
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }
    }
}

模板代码如下:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        ...
    }
    buildTypes {
        ...
    }

    lintOptions {
       ...
    }
}

dependencies {
    ...
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }
    }
}
 

相关文章:

  • 2021-06-29
  • 2022-12-23
  • 2021-04-14
  • 2021-12-26
  • 2022-12-23
  • 2022-02-07
  • 2021-11-29
  • 2022-01-12
猜你喜欢
  • 2021-12-11
  • 2022-02-02
  • 2022-12-23
  • 2021-05-11
  • 2021-07-11
  • 2021-08-17
  • 2022-12-23
相关资源
相似解决方案