Gradle依赖库和版本号统一管理

方法一:



方法二:

1.新建一个config.gradle文件,然后在build.gradle(最外层)中添加applyfrom:"config.gradle"(顶部)

2.设置版本号管理

defaultConfig{

applicationId rootProject.ext.android.applicationId

minSdkVersionrootProject.ext.android.minSdkVersion

targetSdkVersionrootProject.ext.android.targetSdkVersion

versionCode rootProject.ext.android.versionCode

versionName rootProject.ext.android.versionName

}

3.设置库

compilerootProject.ext.dependencies["support-v4"]

compilerootProject.ext.dependencies["butterknife"]

compilerootProject.ext.dependencies["glide"]

4.config.gradle中设置版本号和库

ext{

android = [compileSdkVersion:23,

buildToolsVersion:"23.0.2",

applicationId:"xxx.xxx.xxx",

minSdkVersion:14,

targetSdkVersion:22,

versionCode:2,

versionName:"1.1.0"]

dependencies = ["support-v4":'com.android.support:support-v4:23.1.1',

"appcompat-v7":'com.android.support:appcompat-v7:23.1.1',

"design":'com.android.support:design:23.1.1',

"butterknife":'com.jakewharton:butterknife:7.0.1',

"glide":'com.github.bumptech.glide:glide:3.6.1',

"glide-okhttp-integration":'com.github.bumptech.glide:okhttp-integration:1.3.1']

}

你可能感兴趣的:(Gradle依赖库和版本号统一管理)