配置
新建config.gradle (和项目的build.gradle同级).
内容为:
ext {
android = [compileSdkVersion: 23,
buildToolsVersion: "23.0.3",
applicationId : "me.drakeet.meizhi",
minSdkVersion : 16,
targetSdkVersion : 22,
versionCode : 360,
versionName : "2.6.0"]
dependencies = ["appcompat-v7" : "com.android.support:appcompat-v7:23.4.0",
"design" : "com.android.support:design:23.4.0",
"recyclerview-v7" : "com.android.support:recyclerview-v7:23.4.0",
"nineoldandroids" : "com.nineoldandroids:library:2.4.0",
"picasso" : "com.squareup.picasso:picasso:2.5.2",
"photoview" : "com.github.chrisbanes.photoview:library:1.2.3",
"numberprogressbar" : "com.daimajia.numberprogressbar:library:1.2@aar",
"umeng-analytics" : "com.umeng.analytics:analytics:latest.integration",
"retrofit" : "com.squareup.retrofit:retrofit:1.9.0",
"rxandroid" : "io.reactivex:rxandroid:1.0.0",
"okhttp-urlconnection": "com.squareup.okhttp:okhttp-urlconnection:2.0.0",
"okhttp" : "com.squareup.okhttp:okhttp:2.0.0",
"butterknife" : "com.jakewharton:butterknife:7.0.1",
"otto" : "com.squareup:otto:1.3.8",
"glide" : "com.github.bumptech.glide:glide:3.7.0"]
}
在项目的build.gradle文件中引入
apply from: "config.gradle"
- 这样使用config中的配置就可以管理所有module中的配置了.
使用
在module的build.gradle中:
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
applicationId rootProject.ext.android.applicationId
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
}
...
compile rootProject.ext.dependencies["design"]
compile rootProject.ext.dependencies["appcompat-v7"]
compile rootProject.ext.dependencies["recyclerview-v7"]
compile rootProject.ext.dependencies["picasso"]