Reid Baker
Gradle + Android
What it is + How to get up to speed
01
What is Gradle?
✤ Build system!
✤ Language independent!
✤ Flexible dependency
management !
✤ Built on Groovy!
✤ Future ...
Why should you use Gradle?
✤ Easy setup with Gradle wrapper !
✤ Make builds faster!
✤ Separate editor and compiler!
✤ More...
GradleWrapper
✤ No installation of gradle is needed after setting up !
✤ Sets your version of gradle and where to look for...
Faster you say?
✤ Incremental builds!
✤ Avoid work you don’t need easily ex. only lint debug
builds and proguard release b...
Freedom to update
✤ IDE updates can’t break the build!
✤ Android tool updates can’t break the build!
✤ install<buildtype> ...
It is all about control
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gr...
Control over your apk
android {
compileSdkVersion 17
buildToolsVersion "19.0.1"
!
sourceSets.main {
java.srcDirs = ['src']...
Dependency management
dependencies {
compile project(“:libraries:skitchkit-android")
!
compile ‘com.android.support:suppor...
BuildTypes and BuildFlavors
Release Types!
✤ Ex. Debug, Beta, Release!
✤ Change package!
✤ Change signing key
Build flavors...
Lets look at a real build file
Tips andTricks
✤ ./gradlew uninstall[flavor] will uninstall the previous version!
✤ Shorten commands with camel case ex.

...
Additional Resources
✤ Start by watching this Google IO talk: http://
www.youtube.com/watch?v=LCJAgPkpmR0!
✤ Get up to spe...
Thanks for coming
Follow me on twitter @reidbaker
Upcoming SlideShare
Loading in...5
×

Intro to Gradle + How to get up to speed

497

Published on

An overview of Gradle as well as hard earned tips and tricks to save tons of time and headaches managing your Android builds.

Published in: Software, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
497
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
4
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Intro to Gradle + How to get up to speed

  1. 1. Reid Baker Gradle + Android What it is + How to get up to speed
  2. 2. 01 What is Gradle? ✤ Build system! ✤ Language independent! ✤ Flexible dependency management ! ✤ Built on Groovy! ✤ Future of android development
  3. 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. 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. 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. 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. 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
  8. 8. Control over your apk android { compileSdkVersion 17 buildToolsVersion "19.0.1" ! sourceSets.main { java.srcDirs = ['src'] res.srcDirs = ['res'] manifest.srcFile ‘AndroidManifest.xml’ } ! buildTypes { debug { debuggable true //unnecessary packageNameSuffix '.dev' if (someVariable) { signingConfig signingConfigs.release } } <Other release types> } }
  9. 9. Dependency management dependencies { compile project(“:libraries:skitchkit-android") ! compile ‘com.android.support:support-v4:19.0.+’ ! compile ('com.actionbarsherlock:actionbarsherlock:4.4.0@aar') { exclude group: 'com.android.support', module: 'support-v4' } ! compile files('/Users/rbaker/dev/google-play-services.jar') ! provided 'com.google.android.maps:maps:16_r2' }
  10. 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
  11. 11. Lets look at a real build file
  12. 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. 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
  14. 14. Thanks for coming Follow me on twitter @reidbaker
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×