SlideShare a Scribd company logo
Build your Android App with Gradle
Android new build system
Agenda
• What is Gradle
• Getting started with gradle
• Use cases
• Q&A
Download Meetup Sample Code
– http://goo.gl/qoXAfa
What is gradle
• Gradle is a JVM based project build automation tool that
builds upon the concepts of Apache Ant and Apache
Maven and introduces a Groovy based domain-specific-
language (DSL) instead of the more traditional XML form of
declaring the project configuration.
Installation
• Download the latest android plugin supported Gradle version
• Extract the downloaded zip “gradle-1.10-all.zip” to any
directory
• Configure the GRADLE_HOME environment variable
• set GRADLE_HOME=<installed directoy>gradle-1.10
• set PATH=%PATH%%GRADLE_HOME%bin
• C:> gradle
Gradle Task
• C:> gradle tasks
• Applying the plugin’s to the build file will automatically add set of
build task to run
• assemble
The task to assemble the output(s) of the project
• check
The task to run all the checks.
• build
This task does both assemble and check
• clean
This task cleans the output of the project
Build File Skeleton
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
apply plugin: 'android'
android {
buildToolsVersion "19.0.1"
compileSdkVersion 19
}
Gradle Wrapper
• C:> gradle wrapper
task wrapper(type: Wrapper) {
gradleVersion = '1.10‘
}
/
└── gradlew
└── gradlew.bat
└── gradle
└── wrapper
└── gradle-wrapper.jar
└── gradle-wrapper.properties
Convention Over Configuration
src
└── main
l └── java
l
└── instrumentTest
└── java
sourceSets {
main{
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
Usecase : 1
I have project with multiple library projects, one of which is
required to be shared with one of my colleague who's working
in a another project.
Dependency Management
• dependencies DSL element is part of the standard Gradle
• Can add dependencies on local and remote libraries
• To add a dependency have to provide library on the compile
configuration under dependencies DSL
• Everything added to the compile configuration get packaged in
to the final APK
• Gradle will follow all dependencies transitively
Dependencies On Multiple Projects
• Each projects will have its own build.gradle declaring how it
gets built
• There will be a file called settings.gradle at the root, which
define which folder is a Gradle project
• If there are more than one library, importing order should be
considered on dependencies on each other
Publish Library To Artifact Repo
• Publish artifacts to local artifact repository
Maven Central
● Proper release and
snapshot release
management
Usecase :2
• I want to make a digitally signed and secured release
version of my app
Build types
• This is achieved by buildTypes DSL
• By default, the android plugin automatically sets up the
project to build both a debug and a release version of the
application
• Difference is that the ability to enable debug and how the APK
is signed
• It allows to customize both debug and release versions, as
well as creating other build types
Build Types…
• Build Types can contribute to the build with code and
resources.
• For each Build Type, a new matching sourceSet is created,
under src directory
src/<buildtypename>/
• This means the Build Type names cannot be main or
instrumentTest
Signing APK
• Android system will not install or run an application that is not
signed appropriately.
• To sign an APK have to make use of signingConfigs DSL
Obfuscating
• Tool ProGuard is used automatically to obfuscate the APK
• It will rename classes, fields, and methods with semantically
obscure names to make it difficult to reverse engineer.
• Android plugin support proguard version is 4.10
• ProGuard will shrinks, optimizes, and remove unused code
which will result smaller APK
Usecase : 3
• I want to make a free version of my application with less
features and commercial version with all features.
Build Variants
– Different versions of the same application or Same
application packaged differently or combination of both.
• Have to occupy productFlavors DSL
• Build Type + Product Flavor = Build Variant
• Product flavor will generate APK’s for all possible
combinations of Build Types and Product Flavors
Debug Release
Free Free-Debug Free-Release
Commercial Commercial-Debug Commercial-Release
Usecase : 4
I want to unit test my project with a testing framework,
Testing
• No need to have a separate test project any more it is
integrated to the application project
• Default location for the instrument test cases are located in
src/instrumentTest
• Test APK is built to test the app under test using the Android
instrumentation framework
• No need to have a AndroidManifest.xml for the app, cause it
will get generated automatically
• Test app manifest is automatically get filled with the package
name and the instrument test runner
Usecase : 5
• I want to measure the quality of my source code continuously
with some quality tools by Integrate it with a Continuous
Integration System
Q&A
Thank you

More Related Content

PDF
Using Docker for Testing
PPTX
Modern Tools for Building Progressive Web Apps
PPTX
Devops and git basics
PPTX
Skip Staging! Test Docker, Helm, and Kubernetes Apps like a Pro
PPTX
Better java with design
PPTX
Porting Projects to .NET 5
PDF
It’s 2021. Why are we -still- rebooting for patches? A look at Live Patching.
PPTX
GitLab for CI/CD process
Using Docker for Testing
Modern Tools for Building Progressive Web Apps
Devops and git basics
Skip Staging! Test Docker, Helm, and Kubernetes Apps like a Pro
Better java with design
Porting Projects to .NET 5
It’s 2021. Why are we -still- rebooting for patches? A look at Live Patching.
GitLab for CI/CD process

What's hot (20)

PPTX
Anatomy of a Build Pipeline
PDF
QConSP 2014 - Continuous Delivery - Part 03 - Continuous Integration
PDF
Introduction to Docker - Learning containerization XP conference 2016
PPTX
2015 05-06-karsten gaebert-akademie-etrainings
PDF
Git slides
PDF
Building a Secure Supply Chain with Docker
PPTX
SkyBase - a Devops Platform for Hybrid Cloud
PDF
13 practical tips for writing secure golang applications
PDF
Agnostic Continuous Delivery
ODP
Learn Continuous Integration with Jenkins All in One Guide
PPTX
Selenium Testing your Kubernetes Apps with Machine Learning and Testim
PDF
A Reference Architecture to Enable Visibility and Traceability across the Ent...
PDF
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
PDF
Microservices Testing at Scale
PDF
Cloud Native Testing, 2020 Edition: A Modern Blueprint for Pre-production Tes...
PDF
GitHub as a Landing Page
PPTX
From Continuous Integration to DevOps
PDF
Designing and Debugging Mobile Apps with an Embedded, Scriptable Web Server
PDF
Lessons learned: Choosing your documentation system
PDF
Gerrit linuxtag2011
Anatomy of a Build Pipeline
QConSP 2014 - Continuous Delivery - Part 03 - Continuous Integration
Introduction to Docker - Learning containerization XP conference 2016
2015 05-06-karsten gaebert-akademie-etrainings
Git slides
Building a Secure Supply Chain with Docker
SkyBase - a Devops Platform for Hybrid Cloud
13 practical tips for writing secure golang applications
Agnostic Continuous Delivery
Learn Continuous Integration with Jenkins All in One Guide
Selenium Testing your Kubernetes Apps with Machine Learning and Testim
A Reference Architecture to Enable Visibility and Traceability across the Ent...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
Microservices Testing at Scale
Cloud Native Testing, 2020 Edition: A Modern Blueprint for Pre-production Tes...
GitHub as a Landing Page
From Continuous Integration to DevOps
Designing and Debugging Mobile Apps with an Embedded, Scriptable Web Server
Lessons learned: Choosing your documentation system
Gerrit linuxtag2011
Ad

Viewers also liked (15)

PPTX
Presentation on collaboration
PDF
updated as on 17May 2016 Resume
DOCX
Resume Linkin
PDF
Póster tour grupal a china julio 2016
DOCX
PPT
Social media a gyakorlatban prezentáció
PDF
Phoenix Perry - Maker Assembly
PDF
Dependency Management on iOS
PPTX
How to Develop and Deploy Web-Scale Applications on AWS
PPTX
Understanding clinical data exchange and cda (hl7 201)
PDF
Multithreading on iOS
PPTX
FUNDAMENTOS DE LAS HERRAMIENTAS WEB 2.0
PDF
branding and design in B2B companies
PDF
Understanding Generation Z - Presented at the HR Leader Talk with Hery Kustan...
Presentation on collaboration
updated as on 17May 2016 Resume
Resume Linkin
Póster tour grupal a china julio 2016
Social media a gyakorlatban prezentáció
Phoenix Perry - Maker Assembly
Dependency Management on iOS
How to Develop and Deploy Web-Scale Applications on AWS
Understanding clinical data exchange and cda (hl7 201)
Multithreading on iOS
FUNDAMENTOS DE LAS HERRAMIENTAS WEB 2.0
branding and design in B2B companies
Understanding Generation Z - Presented at the HR Leader Talk with Hery Kustan...
Ad

Similar to Build your android app with gradle (20)

PDF
Gradle enabled android project
PPTX
Exploring the power of Gradle in android studio - Basics & Beyond
PPTX
Gradle,the new build system for android
PDF
Gradle and Your Android Wearable Projects
PPTX
Android presentation - Gradle ++
PDF
Gradle-based Android Build System
PDF
Gradle presentation
PPTX
Faster Java EE Builds with Gradle
PPTX
Faster Java EE Builds with Gradle
PPTX
A brief guide to android gradle
PPTX
Faster java ee builds with gradle [con4921]
PPTX
Gradle basics
PDF
Android gradle-build-system-overview
PPTX
Android, Gradle & Dependecies
PDF
Gradle - the Enterprise Automation Tool
PDF
Building android apps with Gradle (GREACH 2015)
PDF
Intro to Gradle + How to get up to speed
PPTX
Gradle build capabilities
PDF
Head first android apps dev tools
PDF
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle enabled android project
Exploring the power of Gradle in android studio - Basics & Beyond
Gradle,the new build system for android
Gradle and Your Android Wearable Projects
Android presentation - Gradle ++
Gradle-based Android Build System
Gradle presentation
Faster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
A brief guide to android gradle
Faster java ee builds with gradle [con4921]
Gradle basics
Android gradle-build-system-overview
Android, Gradle & Dependecies
Gradle - the Enterprise Automation Tool
Building android apps with Gradle (GREACH 2015)
Intro to Gradle + How to get up to speed
Gradle build capabilities
Head first android apps dev tools
Gradle build tool that rocks with DSL JavaOne India 4th May 2012

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Getting Started with Data Integration: FME Form 101
PPTX
Machine Learning_overview_presentation.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Programs and apps: productivity, graphics, security and other tools
Reach Out and Touch Someone: Haptics and Empathic Computing
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity
NewMind AI Weekly Chronicles - August'25-Week II
“AI and Expert System Decision Support & Business Intelligence Systems”
gpt5_lecture_notes_comprehensive_20250812015547.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Tartificialntelligence_presentation.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Getting Started with Data Integration: FME Form 101
Machine Learning_overview_presentation.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
1. Introduction to Computer Programming.pptx
Encapsulation theory and applications.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Dropbox Q2 2025 Financial Results & Investor Presentation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

Build your android app with gradle

  • 1. Build your Android App with Gradle Android new build system
  • 2. Agenda • What is Gradle • Getting started with gradle • Use cases • Q&A
  • 3. Download Meetup Sample Code – http://goo.gl/qoXAfa
  • 4. What is gradle • Gradle is a JVM based project build automation tool that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy based domain-specific- language (DSL) instead of the more traditional XML form of declaring the project configuration.
  • 5. Installation • Download the latest android plugin supported Gradle version • Extract the downloaded zip “gradle-1.10-all.zip” to any directory • Configure the GRADLE_HOME environment variable • set GRADLE_HOME=<installed directoy>gradle-1.10 • set PATH=%PATH%%GRADLE_HOME%bin • C:> gradle
  • 6. Gradle Task • C:> gradle tasks • Applying the plugin’s to the build file will automatically add set of build task to run • assemble The task to assemble the output(s) of the project • check The task to run all the checks. • build This task does both assemble and check • clean This task cleans the output of the project
  • 7. Build File Skeleton buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' } } apply plugin: 'android' android { buildToolsVersion "19.0.1" compileSdkVersion 19 }
  • 8. Gradle Wrapper • C:> gradle wrapper task wrapper(type: Wrapper) { gradleVersion = '1.10‘ } / └── gradlew └── gradlew.bat └── gradle └── wrapper └── gradle-wrapper.jar └── gradle-wrapper.properties
  • 9. Convention Over Configuration src └── main l └── java l └── instrumentTest └── java sourceSets { main{ manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } instrumentTest.setRoot('tests') }
  • 10. Usecase : 1 I have project with multiple library projects, one of which is required to be shared with one of my colleague who's working in a another project.
  • 11. Dependency Management • dependencies DSL element is part of the standard Gradle • Can add dependencies on local and remote libraries • To add a dependency have to provide library on the compile configuration under dependencies DSL • Everything added to the compile configuration get packaged in to the final APK • Gradle will follow all dependencies transitively
  • 12. Dependencies On Multiple Projects • Each projects will have its own build.gradle declaring how it gets built • There will be a file called settings.gradle at the root, which define which folder is a Gradle project • If there are more than one library, importing order should be considered on dependencies on each other
  • 13. Publish Library To Artifact Repo • Publish artifacts to local artifact repository Maven Central ● Proper release and snapshot release management
  • 14. Usecase :2 • I want to make a digitally signed and secured release version of my app
  • 15. Build types • This is achieved by buildTypes DSL • By default, the android plugin automatically sets up the project to build both a debug and a release version of the application • Difference is that the ability to enable debug and how the APK is signed • It allows to customize both debug and release versions, as well as creating other build types
  • 16. Build Types… • Build Types can contribute to the build with code and resources. • For each Build Type, a new matching sourceSet is created, under src directory src/<buildtypename>/ • This means the Build Type names cannot be main or instrumentTest
  • 17. Signing APK • Android system will not install or run an application that is not signed appropriately. • To sign an APK have to make use of signingConfigs DSL
  • 18. Obfuscating • Tool ProGuard is used automatically to obfuscate the APK • It will rename classes, fields, and methods with semantically obscure names to make it difficult to reverse engineer. • Android plugin support proguard version is 4.10 • ProGuard will shrinks, optimizes, and remove unused code which will result smaller APK
  • 19. Usecase : 3 • I want to make a free version of my application with less features and commercial version with all features.
  • 20. Build Variants – Different versions of the same application or Same application packaged differently or combination of both. • Have to occupy productFlavors DSL • Build Type + Product Flavor = Build Variant • Product flavor will generate APK’s for all possible combinations of Build Types and Product Flavors Debug Release Free Free-Debug Free-Release Commercial Commercial-Debug Commercial-Release
  • 21. Usecase : 4 I want to unit test my project with a testing framework,
  • 22. Testing • No need to have a separate test project any more it is integrated to the application project • Default location for the instrument test cases are located in src/instrumentTest • Test APK is built to test the app under test using the Android instrumentation framework • No need to have a AndroidManifest.xml for the app, cause it will get generated automatically • Test app manifest is automatically get filled with the package name and the instrument test runner
  • 23. Usecase : 5 • I want to measure the quality of my source code continuously with some quality tools by Integrate it with a Continuous Integration System
  • 24. Q&A