美文网首页
解决com.android.support版本冲突问题

解决com.android.support版本冲突问题

作者: 好学人 | 来源:发表于2019-04-20 14:04 被阅读0次

项目中不同Modulesupport包版本冲突怎么办?

只需要将以下代码复制到每个模块的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'
            }
        }
    }
}

相关文章

网友评论

      本文标题:解决com.android.support版本冲突问题

      本文链接:https://www.haomeiwen.com/subject/usakgqtx.html