post score
times, average :
Because Android studio and Android related SDKs and build tools have extremely fast update speeds.Modifications to relevant versions are sometimes more sensitive, especially in team projects where individuals modify the version of the relevant tool locally and accidentally submit it to a remote code repository. Others often have problems updating.The version field in the Android studio project file is very scattered. When the SDK environment changes, it is still more troublesome to modify.This article uses configuration files to centrally control build tool versions.
The gradle.properties file defines version information and assigns values in the project root directory
1 2 3 4 5 |
GradleBuildVersion=2.1.2 AndroidMinSDKVersion=16 AndroidTargetVersion=23 AndroidCompileSDKVersion=23 AndroidBuildToolsVersion=23.0.1 |
Reference gradle variable where version information is used
Dependencies
1 2 3 4 5 |
Dependencies { Compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' Compile 'com.android.support:appcompat-v7:'+project.AndroidBuildToolsVersion } |
Build.gradle(project)
1 2 3 4 5 6 7 8 9 10 |
Buildscript { Repositories { Jcenter() } Dependencies { Classpath 'com.android.tools.build:gradle:'+project.GradleBuildVersion // NOTE: Do not place your application dependencies here; // in the individual module build.gradle files } } |
Build.gradle(module)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Android { compileSdkVersion Integer.parseInt(project.AndroidCompileSDKVersion) buildToolsVersion project.AndroidBuildToolsVersion defaultConfig { applicationId "cn.wangbaiyuan.plugintest" minSdkVersion Integer.parseInt(project.AndroidMinSDKVersion) targetSdkVersion Integer.parseInt(project.AndroidTargetVersion) versionCode 1 versionName "1.0" } buildTypes { Release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } |
This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!
Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/gradle-using-configuration-files-build-tools-version-under-centralized-control-2.html
No Comment