• Like
Intro to Gradle + How to get up to speed
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Intro to Gradle + How to get up to speed

  • 262 views
Published

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

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
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
262
On SlideShare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Reid Baker Gradle + Android What it is + How to get up to speed
  • 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
  • 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. 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. 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. Lets look at a real build file
  • 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
  • 14. Thanks for coming Follow me on twitter @reidbaker