In order to improve the efficiency of project development, some open source frameworks are often introduced in the actual project development process, as well as various modules used in the project. When too many modules are introduced, it is better to provide a unified way to manage version numbers, such as compileSdkVersion, buildToolsVersion, and Android testcompile It is convenient to maintain the version number in the future. Here is a way to deal with the above problems.
The method is as follows:
1.1 add ext { Content in.}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
/*SDK And Tools(SDK And tools)*/
//SDK version for compilation
compileSdkVersion = 26
//Tool version for Gradle compilation project
buildToolsVersion = "26.0.1"
//Android version minimum supported
minSdkVersion = 15
//Target version
targetSdkVersion = 26
//Application version number
versionCode = 100
//Application version name
versionName = "1.0.0"
/*Dependencies(Dependency)*/
supportLibVersion = "26.0.0-alpha1"
}
1.2 use in build.gradle under app Directory:
- 1.2.1 rootProject.ext.compileSdkVersion{......}
- 1.2.2 $rootProject.supportLibVersion
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$rootProject.supportLibVersion"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
Download address:
https://download.csdn.net/download/lvluffy/10318038