2. 01
What is Gradle?
✤ Build system!
✤ Language independent!
✤ Flexible dependency
management !
✤ Built on Groovy!
✤ Future of android development
3. Why should you use Gradle?
✤ Easy setup with Gradle wrapper !
✤ Make builds faster!
✤ Separate editor and compiler!
✤ More control over your builds!
✤ Control build tools versions!
✤ Change properties!
✤ Manage dependencies
4. GradleWrapper
✤ No installation of gradle is needed after setting up !
✤ Sets your version of gradle and where to look for it!
✤ Works for *NIX and Windows!
✤ ./gradlew tasks will list what you can do
5. Faster you say?
✤ Incremental builds!
✤ Avoid work you don’t need easily ex. only lint debug
builds and proguard release builds!
✤ Set flags in settings.gradle to make gradle faster
org.gradle.daemon=true
6. Freedom to update
✤ IDE updates can’t break the build!
✤ Android tool updates can’t break the build!
✤ install<buildtype> will assemble your apk and install it to the
connected device!
✤ Dependencies are stored locally in the build directory
7. It is all about control
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
}
}
apply plugin: ‘android’
!
repositories {
maven {
url “https://maven.vpn.etonreve.com/repo”
}
}
!
//Where should I find the android tools
//What version of the android tools
!
//Tell gradle to we want to use the
android plugin
!
//Where are the android dependancies
located
10. BuildTypes and BuildFlavors
Release Types!
✤ Ex. Debug, Beta, Release!
✤ Change package!
✤ Change signing key
Build flavors!
✤ Ex. Architecture,
Free/Premium
Branding!
✤ Can be grouped !
✤ Can have different src
and res directories
12. Tips andTricks
✤ ./gradlew uninstall[flavor] will uninstall the previous version!
✤ Shorten commands with camel case ex.
./gradlew installAllArchEvernoteDebug
./gradlew iAAED!
!
!
✤ Handy command line arguments
--offline flag while building to not go to the server
--refresh-dependencies to tell Gradle to fetch all new dependencies !
✤ Dependencies are cached for 24 hours but you can change how long
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 4, ‘hours’
}!
!
✤ .aar file is a zip. you can unzip it to see what’s inside.!
!
✤ Install the groovy shell to quickly verify that your groovy does what it is supposed to!
13. Additional Resources
✤ Start by watching this Google IO talk: http://
www.youtube.com/watch?v=LCJAgPkpmR0!
✤ Get up to speed with Groovy: http://groovy.codehaus.org/
Groovy+style+and+language+feature+guidelines+for+Java
+developers!
✤ Get up to speed with Gradle: http://fbflex.wordpress.com/
2013/05/01/12-new-things-i-learned-from-a-three-day-
gradle-training/!
✤ More info about resource merging http://tools.android.com/
tech-docs/new-build-system/resource-merging