SlideShare a Scribd company logo
Hands on the Gradle 
+Konstantin Zgirovskiy 
@silentnuke 
silentnuke09@gmail.com
Good to be programmer…
Build problems (before Gradle) 
● Several weakly compatible versions of building 
● Difficult dependency management 
● Hard to generate several variants of the application
What is gradle? 
• Ant makes you reinvent the wheel every time 
• Ant build scripts can get hard to maintain very quickly 
• Maven does not care about your project, you must make sure 
that your project works well with Maven – it enforces 
convention 
• You must do everything “The Maven Way” or implement 
custom plugins 
• Gradle combines the power and flexibility of Ant with 
dependency management of Ivy and conventions of Maven 
• Gradle is a programming build tool with DSL based on Groovy
Why gradle? 
• Built-in dependency management through Maven 
and/or Ivy 
• Make it easy to configure, extend and customize the 
build process 
• Make it easy to reuse code and resources 
• Make it easy to create several variants of an application, 
either for multi-apk distribution or for different flavors 
of an application 
• Good IDE Integration
Basiс Gradle Config 
buildscript { 
repositories { 
mavenCentral() 
} 
dependencies { 
classpath 'com.android.tools.build:gradle:0.14.0' 
} 
} 
apply plugin: 'com.android.application' 
android { 
compileSdkVersion 19 
buildToolsVersion "21.0.2" 
}
Dependencies 
• Maven, Ivy – artifacts 
Remote and local 
• Local files 
Jar 
Other gradle-projects 
AAR
Dependencies 
dependencies { 
compile 'com.android.support:support-v4:21.0.0‘ 
compile 'org.apache.commons:commons-collections4:4.0' 
compile project(':libraries:catalitClient') 
compile files('libs/AF-Android-SDK-v2.3.1.11.jar') 
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' 
}
Build customization 
• Example: debug / release 
• Might have own 
o Dependencies 
o Resources 
o Special settings
Build types 
• Default 
o debug 
o release 
• What can configure 
o packageNameSuffix 
o BuildConfig.java 
o Own recourses/code 
o Other
Build customization 
android { 
defaultConfig { 
applicationId 'ru.litres.android' 
minSdkVersion 8 
targetSdkVersion 19 
versionCode 20141009 
versionName "2.14.5" 
} 
buildTypes { 
debug { 
packageNameSuffix ".debug" 
buildConfigField “String", " HOST_URL ", ‘”debug.litres.ru”’ 
} 
release { 
buildConfigField “String", “HOST_URL", ‘”release.litres.ru”’ 
} 
}
Build flavors 
• Ability to easy generate few different apk. 
• Example 
o Paid / free 
o Partner app 
o Building multiple apk (abi, density) 
o Other cases
Build customization 
android { 
flavorDimensions 'store' 
productFlavors { 
googlePlay { 
flavorDimension 'store' 
} 
samsungApps { 
flavorDimension 'store' 
buildConfigField "boolean", "IS_SAMSUNG_APPS_BUILD", "true" 
} 
amazon { 
flavorDimension 'store' 
buildConfigField "boolean", "IS_AMAZON_BUILD", "true" 
} 
} 
}
Build variants 
Flavor 
Build 
Free 
Paid 
FreeDebug FreeRelease 
PaidDebug 
PaidRelease 
Debug Release 
BuildVariant
Source sets 
• src/ 
main/ 
• java/ 
• res/ 
• … 
AndroidManifest.xml 
• paid/ 
• free/
Source sets for BuildType 
anв Flavor 
• src/ 
• main/ 
• release/ 
• debug/ 
• free/ 
• paid/
Build the app 
main 
free 
debug
Resources and placeholders 
android { 
productFlavors { 
readFree{ 
applicationId 'ru.litres.android.readfree' 
versionCode 20141009 
versionName "2.14.5" 
resValue 'string', 'provider_search_authorities', 
'ru.litres.android.readfree.SearchProvider' 
resValue 'string', 'package_name', 'ru.litres.android.readfree‘ 
manifestPlaceholders = [adviatorPackage: "av111363.android", 
adviatorServiceName: "av111363.android.S111363", 
adviatorAppId: “app id", 
adviatorAppKey: “somes secret"] 
} 
} 
}
AndroidManifest.xml 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="ru.litres.android"> 
<permission 
android:name="${applicationId}.permission.C2D_MESSAGE" 
android:protectionLevel="signature" /> 
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" /> 
<application> 
<provider 
android:name="ru.litres.android.providers.BookSuggestionProvider" 
android:authorities="@string/provider_search_authorities" /> 
<meta-data 
android:name="ADVIATOR_APPID" 
android:value="id:${adviatorAppId}" /> 
<meta-data 
android:name="ADVIATOR_APPKEY" 
android:value="key:${adviatorAppKey}" /> 
<service 
android:name="com.${adviatorServiceName}" 
android:exported="false" /> 
</application> 
</manifest>
Build customization 
res/xml/searchable.xml 
<searchable xmlns:android="http://schemas.android.com/apk/res/android" 
android:hint="@string/searchable_hint" 
android:label="@string/app_name" 
android:searchSuggestAuthority="@string/provider_search_authorities" 
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" /> 
res/xml/main_settings.xml 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > 
<PreferenceCategory android:title="@string/settings_info" > 
<Preference android:title="@string/about_program" > 
<intent 
android:targetClass="ru.litres.android.ui.AboutActivity" 
android:targetPackage="@string/package_name" /> 
</Preference> 
</PreferenceCategory> 
</PreferenceScreen>
Splits 
android { 
flavorDimensions 'store‘, ‘abi’ 
productFlavors { 
arm { 
flavorDimension 'abi' 
versionCode Integer.parseInt("1" + defaultConfig.versionCode) 
ndk { 
abiFilter "armeabi" 
} 
} 
armv7 { 
flavorDimension 'abi' 
versionCode Integer.parseInt("2" + defaultConfig.versionCode) 
ndk { 
abiFilter "armeabi-v7a" 
} 
} 
} 
}
Splits 
android { 
project.ext.abiVersionCodesPrefix = ['armeabi':1, 'armeabi-v7a':2, 'mips':4, 
x86':6] 
splits { 
abi { 
enable true 
reset() 
include 'armeabi', 'armeabi-v7a', 'mips', 'x86' 
universalApk false 
} 
} 
applicationVariants.all { variant -> 
variant.outputs.each { output -> 
output.versionCodeOverride = 
Integer.parseInt(project.ext.abiVersionCodesPrefix.get(output.getFilter(com. 
android.build.OutputFile.ABI), 0) + "" + variant.mergedFlavor.versionCode) 
} 
} 
} 
}
Android Gradle plugin 
docs SUCK :-( 
But community rocks :) 
+Android Developer Tools 
http://goo.gl/hAnxTf 
+Tor Norbye 
+Alex Ruiz [gradle, android]
Resources 
http://www.gradle.org 
http://tools.android.com/tech-docs/new-build-system 
http://gradleplease.appspot.com/ 
https://groups.google.com/forum/#!forum/adt-dev 
http://stackoverflow.com/
Thank you! 
Q&A 
+Konstantin Zgirovskiy 
@silentnuke 
silentnuke09@gmail.com

More Related Content

What's hot

Android Internal Library Management
Android Internal Library ManagementAndroid Internal Library Management
Android Internal Library Management
Kelly Shuster
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
A Story about AngularJS modularization development
A Story about AngularJS modularization developmentA Story about AngularJS modularization development
A Story about AngularJS modularization development
Johannes Weber
 
Micronaut: A new way to build microservices
Micronaut: A new way to build microservicesMicronaut: A new way to build microservices
Micronaut: A new way to build microservices
Luram Archanjo
 
Introduction to Codenvy / JugSummerCamp 2014
Introduction to Codenvy / JugSummerCamp 2014Introduction to Codenvy / JugSummerCamp 2014
Introduction to Codenvy / JugSummerCamp 2014
Florent BENOIT
 
.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ
Avijit Shaw
 
Running Spring Boot Applications as GraalVM Native Images
Running Spring Boot Applications as GraalVM Native ImagesRunning Spring Boot Applications as GraalVM Native Images
Running Spring Boot Applications as GraalVM Native Images
VMware Tanzu
 
Spring Native and Spring AOT
Spring Native and Spring AOTSpring Native and Spring AOT
Spring Native and Spring AOT
VMware Tanzu
 
Unpacking .NET Core | EastBanc Technologies
Unpacking .NET Core | EastBanc TechnologiesUnpacking .NET Core | EastBanc Technologies
Unpacking .NET Core | EastBanc Technologies
EastBanc Tachnologies
 
JPQL/ JPA Activity 1
JPQL/ JPA Activity 1JPQL/ JPA Activity 1
JPQL/ JPA Activity 1
SFI
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
David Amend
 
Gradle
GradleGradle
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
Bhagwat Kumar
 
Top 8 benefits of react js
Top 8 benefits of react jsTop 8 benefits of react js
Top 8 benefits of react js
Rani Sinha
 
React Vs AnagularJS
React Vs AnagularJSReact Vs AnagularJS
React Vs AnagularJS
deepakpatil84
 
Ajax toolkit framework
Ajax toolkit frameworkAjax toolkit framework
Ajax toolkit framework
Sunil Kumar
 
Android
AndroidAndroid
Android
BVP GTUG
 
Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
Mallikarjuna G D
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
sparkfabrik
 
Multiplatform Apps with Spring, Kotlin, and RSocket
Multiplatform Apps with Spring, Kotlin, and RSocketMultiplatform Apps with Spring, Kotlin, and RSocket
Multiplatform Apps with Spring, Kotlin, and RSocket
VMware Tanzu
 

What's hot (20)

Android Internal Library Management
Android Internal Library ManagementAndroid Internal Library Management
Android Internal Library Management
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
A Story about AngularJS modularization development
A Story about AngularJS modularization developmentA Story about AngularJS modularization development
A Story about AngularJS modularization development
 
Micronaut: A new way to build microservices
Micronaut: A new way to build microservicesMicronaut: A new way to build microservices
Micronaut: A new way to build microservices
 
Introduction to Codenvy / JugSummerCamp 2014
Introduction to Codenvy / JugSummerCamp 2014Introduction to Codenvy / JugSummerCamp 2014
Introduction to Codenvy / JugSummerCamp 2014
 
.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ
 
Running Spring Boot Applications as GraalVM Native Images
Running Spring Boot Applications as GraalVM Native ImagesRunning Spring Boot Applications as GraalVM Native Images
Running Spring Boot Applications as GraalVM Native Images
 
Spring Native and Spring AOT
Spring Native and Spring AOTSpring Native and Spring AOT
Spring Native and Spring AOT
 
Unpacking .NET Core | EastBanc Technologies
Unpacking .NET Core | EastBanc TechnologiesUnpacking .NET Core | EastBanc Technologies
Unpacking .NET Core | EastBanc Technologies
 
JPQL/ JPA Activity 1
JPQL/ JPA Activity 1JPQL/ JPA Activity 1
JPQL/ JPA Activity 1
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
 
Gradle
GradleGradle
Gradle
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
Top 8 benefits of react js
Top 8 benefits of react jsTop 8 benefits of react js
Top 8 benefits of react js
 
React Vs AnagularJS
React Vs AnagularJSReact Vs AnagularJS
React Vs AnagularJS
 
Ajax toolkit framework
Ajax toolkit frameworkAjax toolkit framework
Ajax toolkit framework
 
Android
AndroidAndroid
Android
 
Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
 
Multiplatform Apps with Spring, Kotlin, and RSocket
Multiplatform Apps with Spring, Kotlin, and RSocketMultiplatform Apps with Spring, Kotlin, and RSocket
Multiplatform Apps with Spring, Kotlin, and RSocket
 

Similar to Hands on the gradle

Intro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speedIntro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speed
Reid Baker
 
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
Dicoding
 
Getting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle pluginGetting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle plugin
tobiaspreuss
 
Android gradle-build-system-overview
Android gradle-build-system-overviewAndroid gradle-build-system-overview
Android gradle-build-system-overview
Kevin He
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
aswapnal
 
AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018 AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018
Theerasan Tonthongkam
 
Tips & Tricks Android
Tips & Tricks AndroidTips & Tricks Android
Tips & Tricks Android
intive
 
Ii 1300-java essentials for android
Ii 1300-java essentials for androidIi 1300-java essentials for android
Ii 1300-java essentials for android
Adrian Mikeliunas
 
Apache Cordova 4.x
Apache Cordova 4.xApache Cordova 4.x
Apache Cordova 4.x
Ivano Malavolta
 
Native Android Development with Spring
Native Android Development with SpringNative Android Development with Spring
Native Android Development with Spring
Roy Clarkson
 
Android Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start GuideAndroid Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start Guide
Sergii Zhuk
 
Android
Android Android
Android
Ravina Bhavsar
 
Android - Anroid Pproject
Android - Anroid PprojectAndroid - Anroid Pproject
Android - Anroid Pproject
Vibrant Technologies & Computers
 
Kasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applicationsKasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applications
LibbySchulze
 
Android 101 - Introduction to Android Development
Android 101 - Introduction to Android DevelopmentAndroid 101 - Introduction to Android Development
Android 101 - Introduction to Android Development
Andy Scherzinger
 
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Somkiat Khitwongwattana
 
Gradle presentation
Gradle presentationGradle presentation
Gradle presentation
Oriol Jiménez
 
Intro to android (gdays)
Intro to android (gdays)Intro to android (gdays)
Intro to android (gdays)
Omolara Adejuwon
 
Android, Gradle & Dependecies
Android, Gradle & DependeciesAndroid, Gradle & Dependecies
Android, Gradle & Dependecies
Édipo Souza
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android Application
Nandini Prabhu
 

Similar to Hands on the gradle (20)

Intro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speedIntro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speed
 
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
 
Getting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle pluginGetting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle plugin
 
Android gradle-build-system-overview
Android gradle-build-system-overviewAndroid gradle-build-system-overview
Android gradle-build-system-overview
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018 AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018
 
Tips & Tricks Android
Tips & Tricks AndroidTips & Tricks Android
Tips & Tricks Android
 
Ii 1300-java essentials for android
Ii 1300-java essentials for androidIi 1300-java essentials for android
Ii 1300-java essentials for android
 
Apache Cordova 4.x
Apache Cordova 4.xApache Cordova 4.x
Apache Cordova 4.x
 
Native Android Development with Spring
Native Android Development with SpringNative Android Development with Spring
Native Android Development with Spring
 
Android Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start GuideAndroid Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start Guide
 
Android
Android Android
Android
 
Android - Anroid Pproject
Android - Anroid PprojectAndroid - Anroid Pproject
Android - Anroid Pproject
 
Kasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applicationsKasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applications
 
Android 101 - Introduction to Android Development
Android 101 - Introduction to Android DevelopmentAndroid 101 - Introduction to Android Development
Android 101 - Introduction to Android Development
 
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
 
Gradle presentation
Gradle presentationGradle presentation
Gradle presentation
 
Intro to android (gdays)
Intro to android (gdays)Intro to android (gdays)
Intro to android (gdays)
 
Android, Gradle & Dependecies
Android, Gradle & DependeciesAndroid, Gradle & Dependecies
Android, Gradle & Dependecies
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android Application
 

Recently uploaded

SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
Kamal Acharya
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
vmspraneeth
 
Open Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surfaceOpen Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surface
Indrajeet sahu
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
nedcocy
 
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
OKORIE1
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
MadhavJungKarki
 
Ericsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.pptEricsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.ppt
wafawafa52
 
FULL STACK PROGRAMMING - Both Front End and Back End
FULL STACK PROGRAMMING - Both Front End and Back EndFULL STACK PROGRAMMING - Both Front End and Back End
FULL STACK PROGRAMMING - Both Front End and Back End
PreethaV16
 
Introduction to Computer Networks & OSI MODEL.ppt
Introduction to Computer Networks & OSI MODEL.pptIntroduction to Computer Networks & OSI MODEL.ppt
Introduction to Computer Networks & OSI MODEL.ppt
Dwarkadas J Sanghvi College of Engineering
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
ijseajournal
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
felixwold
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
Roger Rozario
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
mahaffeycheryld
 
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Transcat
 
OOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming languageOOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming language
PreethaV16
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 

Recently uploaded (20)

SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
 
Open Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surfaceOpen Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surface
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
 
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
 
Ericsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.pptEricsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.ppt
 
FULL STACK PROGRAMMING - Both Front End and Back End
FULL STACK PROGRAMMING - Both Front End and Back EndFULL STACK PROGRAMMING - Both Front End and Back End
FULL STACK PROGRAMMING - Both Front End and Back End
 
Introduction to Computer Networks & OSI MODEL.ppt
Introduction to Computer Networks & OSI MODEL.pptIntroduction to Computer Networks & OSI MODEL.ppt
Introduction to Computer Networks & OSI MODEL.ppt
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
 
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
 
OOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming languageOOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming language
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 

Hands on the gradle

  • 1. Hands on the Gradle +Konstantin Zgirovskiy @silentnuke silentnuke09@gmail.com
  • 2. Good to be programmer…
  • 3. Build problems (before Gradle) ● Several weakly compatible versions of building ● Difficult dependency management ● Hard to generate several variants of the application
  • 4. What is gradle? • Ant makes you reinvent the wheel every time • Ant build scripts can get hard to maintain very quickly • Maven does not care about your project, you must make sure that your project works well with Maven – it enforces convention • You must do everything “The Maven Way” or implement custom plugins • Gradle combines the power and flexibility of Ant with dependency management of Ivy and conventions of Maven • Gradle is a programming build tool with DSL based on Groovy
  • 5. Why gradle? • Built-in dependency management through Maven and/or Ivy • Make it easy to configure, extend and customize the build process • Make it easy to reuse code and resources • Make it easy to create several variants of an application, either for multi-apk distribution or for different flavors of an application • Good IDE Integration
  • 6. Basiс Gradle Config buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.14.0' } } apply plugin: 'com.android.application' android { compileSdkVersion 19 buildToolsVersion "21.0.2" }
  • 7. Dependencies • Maven, Ivy – artifacts Remote and local • Local files Jar Other gradle-projects AAR
  • 8. Dependencies dependencies { compile 'com.android.support:support-v4:21.0.0‘ compile 'org.apache.commons:commons-collections4:4.0' compile project(':libraries:catalitClient') compile files('libs/AF-Android-SDK-v2.3.1.11.jar') compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' }
  • 9. Build customization • Example: debug / release • Might have own o Dependencies o Resources o Special settings
  • 10. Build types • Default o debug o release • What can configure o packageNameSuffix o BuildConfig.java o Own recourses/code o Other
  • 11. Build customization android { defaultConfig { applicationId 'ru.litres.android' minSdkVersion 8 targetSdkVersion 19 versionCode 20141009 versionName "2.14.5" } buildTypes { debug { packageNameSuffix ".debug" buildConfigField “String", " HOST_URL ", ‘”debug.litres.ru”’ } release { buildConfigField “String", “HOST_URL", ‘”release.litres.ru”’ } }
  • 12. Build flavors • Ability to easy generate few different apk. • Example o Paid / free o Partner app o Building multiple apk (abi, density) o Other cases
  • 13. Build customization android { flavorDimensions 'store' productFlavors { googlePlay { flavorDimension 'store' } samsungApps { flavorDimension 'store' buildConfigField "boolean", "IS_SAMSUNG_APPS_BUILD", "true" } amazon { flavorDimension 'store' buildConfigField "boolean", "IS_AMAZON_BUILD", "true" } } }
  • 14. Build variants Flavor Build Free Paid FreeDebug FreeRelease PaidDebug PaidRelease Debug Release BuildVariant
  • 15. Source sets • src/ main/ • java/ • res/ • … AndroidManifest.xml • paid/ • free/
  • 16. Source sets for BuildType anв Flavor • src/ • main/ • release/ • debug/ • free/ • paid/
  • 17. Build the app main free debug
  • 18.
  • 19. Resources and placeholders android { productFlavors { readFree{ applicationId 'ru.litres.android.readfree' versionCode 20141009 versionName "2.14.5" resValue 'string', 'provider_search_authorities', 'ru.litres.android.readfree.SearchProvider' resValue 'string', 'package_name', 'ru.litres.android.readfree‘ manifestPlaceholders = [adviatorPackage: "av111363.android", adviatorServiceName: "av111363.android.S111363", adviatorAppId: “app id", adviatorAppKey: “somes secret"] } } }
  • 20. AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ru.litres.android"> <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" /> <application> <provider android:name="ru.litres.android.providers.BookSuggestionProvider" android:authorities="@string/provider_search_authorities" /> <meta-data android:name="ADVIATOR_APPID" android:value="id:${adviatorAppId}" /> <meta-data android:name="ADVIATOR_APPKEY" android:value="key:${adviatorAppKey}" /> <service android:name="com.${adviatorServiceName}" android:exported="false" /> </application> </manifest>
  • 21. Build customization res/xml/searchable.xml <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:hint="@string/searchable_hint" android:label="@string/app_name" android:searchSuggestAuthority="@string/provider_search_authorities" android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" /> res/xml/main_settings.xml <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory android:title="@string/settings_info" > <Preference android:title="@string/about_program" > <intent android:targetClass="ru.litres.android.ui.AboutActivity" android:targetPackage="@string/package_name" /> </Preference> </PreferenceCategory> </PreferenceScreen>
  • 22. Splits android { flavorDimensions 'store‘, ‘abi’ productFlavors { arm { flavorDimension 'abi' versionCode Integer.parseInt("1" + defaultConfig.versionCode) ndk { abiFilter "armeabi" } } armv7 { flavorDimension 'abi' versionCode Integer.parseInt("2" + defaultConfig.versionCode) ndk { abiFilter "armeabi-v7a" } } } }
  • 23. Splits android { project.ext.abiVersionCodesPrefix = ['armeabi':1, 'armeabi-v7a':2, 'mips':4, x86':6] splits { abi { enable true reset() include 'armeabi', 'armeabi-v7a', 'mips', 'x86' universalApk false } } applicationVariants.all { variant -> variant.outputs.each { output -> output.versionCodeOverride = Integer.parseInt(project.ext.abiVersionCodesPrefix.get(output.getFilter(com. android.build.OutputFile.ABI), 0) + "" + variant.mergedFlavor.versionCode) } } } }
  • 24. Android Gradle plugin docs SUCK :-( But community rocks :) +Android Developer Tools http://goo.gl/hAnxTf +Tor Norbye +Alex Ruiz [gradle, android]
  • 25. Resources http://www.gradle.org http://tools.android.com/tech-docs/new-build-system http://gradleplease.appspot.com/ https://groups.google.com/forum/#!forum/adt-dev http://stackoverflow.com/
  • 26. Thank you! Q&A +Konstantin Zgirovskiy @silentnuke silentnuke09@gmail.com