新建xxx.gradle
ext {
android = [compileSdkVersion: 29,
buildToolsVersion: "29.0.0",
minSdkVersion : 19,
targetSdkVersion : 29,
applicationId : ‘com.imooc.imooc_voice‘,
versionCode : 2,
versionName : ‘1.1‘,
multiDexEnabled : true,]
depsVersion = [appcompact : ‘29.0.0‘,
design : ‘29.0.0‘,
recyclerview : ‘29.0.0‘,
constraint : ‘1.1.3‘,
eventbus : ‘3.1.1‘,
greendao : ‘3.2.2‘,
rxjava : ‘2.2.9‘,
rxandroid : ‘2.1.1‘,
arouterapi : ‘1.5.0‘,
aroutercompiler: ‘1.2.2‘,
magicindicator : ‘1.5.0‘,
glide : ‘4.9.0‘,
glidecompiler : ‘4.9.0‘,
okhttp : ‘3.3.0‘,
gson : ‘2.8.0‘,
]
depsLibs = [appcompact : ‘androidx.appcompat:appcompat:1.0.0‘,
design : ‘com.google.android.material:material:1.0.0‘,
recyclerview : ‘androidx.recyclerview:recyclerview:1.0.0‘,
constraint : ‘androidx.constraintlayout:constraintlayout:1.1.3‘,
eventbus : "org.greenrobot:eventbus:${depsVersion.eventbus}",
greendao : "org.greenrobot:greendao:${depsVersion.greendao}",
rxjava : "io.reactivex.rxjava2:rxjava:${depsVersion.rxjava}",
rxandroid : "io.reactivex.rxjava2:rxandroid:${depsVersion.rxandroid}",
arouterapi : "com.alibaba:arouter-api:${depsVersion.arouterapi}",
aroutercompiler: "com.alibaba:arouter-compiler:${depsVersion.aroutercompiler}",
magicindicator : "com.github.hackware1993:MagicIndicator:${depsVersion.magicindicator}",
glide : "com.github.bumptech.glide:glide:${depsVersion.glide}",
glidecompiler : "com.github.bumptech.glide:compiler:${depsVersion.glidecompiler}",
okhttp : "com.squareup.okhttp3:okhttp:${depsVersion.okhttp}",
gson : "com.google.code.gson:gson:${depsVersion.gson}",
]
}
2. 项目根build.gradle 引入
//引入根工程下的统一版本管理文件
apply from: this.rootProject.file(‘imooc.gradle‘)
3. 每个模块引用
compileSdkVersion rootProject.android.compileSdkVersion
原文:https://www.cnblogs.com/allenxieyusheng/p/11954305.html