Android 统一管理依赖配置

1.新建配置xx.gradle文件

例如:xxx.gradle内容如下

ext {
    Android = [
            compileSdkVersion: 27,
            applicationId    : "com.xxx.xxx",
            minSdkVersion    : 17,
            targetSdkVersion : 27,
            versionCode      : 1,
            versionName      : "1.0"
    ]

    SupportVersion = "27.1.1"

    Dependencies = [
            SupportV7                     : "com.android.support:appcompat-v7:${SupportVersion}",
            SupportV4                     : "com.android.support:support-v4:${SupportVersion}",
            Design                        : "com.android.support:design:${SupportVersion}"
    ]
}

2.在项目根目录build.gradle中加入

apply from: "xxx.gradle"

3.在app目录下配置

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation Dependencies.SupportV7
    implementation Dependencies.ConstraintLayout
    implementation Dependencies.SupportV4
    implementation Dependencies.Design
}

你可能感兴趣的:(Android 统一管理依赖配置)