Last active
June 22, 2020 11:43
-
-
Save segunfamisa/b659ebdb04735475b48a7935d646fd03 to your computer and use it in GitHub Desktop.
Using gradle extra properties to manage Android dependency versioning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app module build.gradle | |
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion rootProject.compileSdkVersion | |
buildToolsVersion rootProject.buildToolsVersion | |
defaultConfig { | |
applicationId "com.segunfamisa.gradleextraproperties" | |
minSdkVersion rootProject.minSdkVersion | |
targetSdkVersion rootProject.targetSdkVersion | |
versionCode 1 | |
versionName "1.0" | |
} | |
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.supportLibraryVersion" | |
compile "com.android.support:design:$rootProject.supportLibraryVersion" | |
compile "com.android.support:percent:$rootProject.supportLibraryVersion" | |
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion" | |
compile "com.android.support:gridlayout-v7:$rootProject.supportLibraryVersion" | |
//play services | |
compile "com.google.android.gms:play-services-location:$rootProject.playServicesVersion" | |
compile "com.google.android.gms:play-services-gcm:$rootProject.playServicesVersion" | |
testCompile "junit:junit:$rootProject.jUnitVersion" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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.0-alpha4' | |
// NOTE: Do not place your application dependencies here; they belong | |
// in the individual module build.gradle files | |
} | |
} | |
allprojects { | |
repositories { | |
jcenter() | |
} | |
} | |
task clean(type: Delete) { | |
delete rootProject.buildDir | |
} | |
ext { | |
// sdk and tools | |
minSdkVersion = 14 | |
targetSdkVersion = 23 | |
compileSdkVersion = 23 | |
buildToolsVersion = '23.0.2' | |
supportLibraryVersion = '23.4.0' | |
playServicesVersion = '9.0.0' | |
jUnitVersion = '4.12' | |
} |
tax
Thank you :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for your sharing.
Noted that we can create own
config.gradle
file and push all the ext values into it, then using across all modules.Pls check my gist:
https://gist.github.com/truongngoclinh/af143066468ec5456cea6867350331fe#file-config-gradle