我们的Android studio工程有时会存在很多共同的构建包
这里我会新建一个gradle 文件
config.gradle
ext{
android = [
applicationId : "net.huansi.loosecloth",
compileSdkVersion : 28,
minSdkVersion : 15,
targetSdkVersion : 28,
versionCode : 1,
versionName : "1.0",
support : "28.0.0"
]
def dependVersion = [
baseform : "19.6.6.1-SNAPSHOT",
retrofit : "2.2.0",
okhttp : "3.6.0",
dagger2 : "2.7",
butterknife : "8.6.0",
glide : "4.5.0",
]
var = \[
//base
appcompat\_v7 : "com.android.support:appcompat-v7:${android.support}",
cardview\_v7 : "com.android.support:cardview-v7:${android.support}",
recyclerview\_v7 : "com.android.support:recyclerview-v7:${android.support}",
design : "com.android.support:design:${android.support}",
rv\_adapter\_helper : "com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.42",
base\_form : "baseform.android.huansi.net:baseform:${dependVersion.baseform}",
//rx
rxjava : "io.reactivex.rxjava2:rxjava:2.2.2",
rxandroid : "io.reactivex.rxjava2:rxandroid:2.0.1",
rxpermissions : "com.tbruyelle.rxpermissions2:rxpermissions:0.9.3@aar",
//network
gson : "com.google.code.gson:gson:2.8.2",
retrofit : "com.squareup.retrofit2:retrofit:${dependVersion.retrofit}",
retrofit\_converter\_gson : "com.squareup.retrofit2:converter-gson:${dependVersion.retrofit}",
retrofit\_adapter\_rxjava2 : "com.squareup.retrofit2:adapter-rxjava2:${dependVersion.retrofit}",
okhttp : "com.squareup.okhttp3:okhttp:${dependVersion.okhttp}",
okhttp\_logging\_interceptor: "com.squareup.okhttp3:logging-interceptor:${dependVersion.okhttp}",
glide : "com.github.bumptech.glide:glide:${dependVersion.glide}",
glide\_compiler : "com.github.bumptech.glide:compiler:${dependVersion.glide}",
glide\_transformations : "jp.wasabeef:glide-transformations:3.0.1",
//di
dagger : "com.google.dagger:dagger:${dependVersion.dagger2}",
dagger\_compiler : "com.google.dagger:dagger-compiler:${dependVersion.dagger2}",
butterknife : "com.jakewharton:butterknife:${dependVersion.butterknife}",
butterknife\_compiler : "com.jakewharton:butterknife-compiler:${dependVersion.butterknife}",
//other
multidex : "com.android.support:multidex:1.0.3",
smart\_refresh : "com.scwang.smartrefresh:SmartRefreshLayout:1.0.5.1",
//滑动轮
wheelview : "com.contrarywind:wheelview:4.0.5",
//相册选择
picture\_selector : "com.github.LuckSiege.PictureSelector:picture\_library:v2.2.0",
//dialog管理
material\_dialog : "com.afollestad.material-dialogs:core:0.9.6.0",
constraint : "com.android.support.constraint:constraint-layout:1.1.3",
autofittextview : "me.grantland:autofittextview:0.2.1"
\]
}
然后在工程的build.gradle中引用
apply from :"config.gradle"
应用到各个module中引用
手机扫一扫
移动阅读更方便
你可能感兴趣的文章