标签:ppc com net pre 中文 sso 版本号 out evel
Gradle统一管理版本号引用配置
为了提高项目开发效率,在实际项目开发过程中往往会引入一些开源框架,还有项目中使用的各种module,moudle过多时最好提供一种统一的方式去管理版本号,如:compileSdkVersion、buildToolsVersion、androidTestCompile 等,便于日后对版本号进行维护,此处记录2种方式处理上述问题。
方式一
1.在项目根目录下创建.gradle文件,如:config.gradle
2.在根目录下的build.gradle文件中引入我们创建的配置文件
3.config.gradle中文件内容可以自己定义,如下示例:
ext {
// 用于编译的SDK版本
COMPILE_SDK_VERSION = 23
// 用于Gradle编译项目的工具版本
BUILD_TOOLS_VERSION = "24.0.2"
// 最低支持Android版本
MIN_SDK_VERSION = 14
// 目标版本
TARGET_SDK_VERSION = 23
// 设置是否使用混淆
MINIFY_ENABLED = true
MINIFY_DISABLED = false
// 应用程序包名
APPLICATION_ID = ‘com.mainiway.eworkpal‘
// Version of "com.android.support:appcompat-v7", refer it as folow:
// compile "com.android.support:appcompat-v7:${APPCOMPAT_VERSION}"
APPCOMPAT_VERSION = ‘23.2.1‘
}4.在app目录下的build.gradle中使用dependencies {
compile fileTree(include: [‘*.jar‘], dir: ‘libs‘)
compile "com.android.support:cardview-v7:${APPCOMPAT_VERSION}"
compile "com.android.support:appcompat-v7:${APPCOMPAT_VERSION}"
compile "com.android.support:design:${APPCOMPAT_VERSION}"
compile ‘com.github.bumptech.glide:glide:3.7.0‘
}1.在根目录下的build.gradle文件下添加 ext{ .... } 中的内容
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath ‘com.android.tools.build:gradle:2.2.3‘
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Define versions in a single place
ext {
// SDK And Tools
minSdkVersion = 14
targetSdkVersion = 23
compileSdkVersion = 23
buildToolsVersion = ‘24.0.2‘
//Dependencies
supportLibraryVersion = ‘23.2.1‘
}apply plugin: ‘com.android.application‘
android {
compileSdkVersion COMPILE_SDK_VERSION
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
applicationId APPLICATION_ID
minSdkVersion MIN_SDK_VERSION
targetSdkVersion TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
}
}
dependencies {
compile fileTree(include: [‘*.jar‘], dir: ‘libs‘)
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:design:$rootProject.supportLibraryVersion"
}Android Studio中Gradle统一管理版本号引用配置
标签:ppc com net pre 中文 sso 版本号 out evel
原文地址:http://blog.csdn.net/gao_chun/article/details/58105089