SlideShare a Scribd company logo
Dependency-Aware Build
Variants in Android Studio 3.0
Stefan Martynkiw
Android Studio 3.0 Introduction
• Introduced at Google I/O 2017
• Improvements:
• Faster Gradle build times
• Profiling tools
• UI
• Network Request Inspection (with Retrofit & OkHTTP)
• Device File Explorer
• App-Private files too! (no more adb run-as!)
• Android Gradle Plugin Improvements
Application Structure and Dependencies
• Applications in Android Studio
can be structured into modules
• Drivewyze Example:
• Agatha (Mobile app)
• Gaby (Stripped down for Android
ELDs)
• Erica (Stripped down for even
older Android ELDs)
• Common
• “Magic Sauce”
Agatha Erica Gaby
Common
Why have variants?
• Production
• Signing Keys, Production
Environment
• QA
• Unsigned, QA test environment
• Development
• Unsigned, Local-host server
Agatha Erica Gaby
Common
Set Theory and the Cross Product
• {A, B, C}
• {A, B, C} ⋈ {D, E, F} =
• AD, AE, AF
• BD, BE, BF
• CD, CE, CF
• {A, B, C} ⋈ {D, E, F} ⋈ {Y, Z} =
• ADY, AEY, AFY
• BDY, BEY, BFY
• CDY, CEY, CFY
• ADZ, AEZ, AFZ
• BDZ, BEZ BFZ
• CDZ, CEZ, CFZ
Abstract  Real
• “Build type”:
• {Debug, Release, Simulated
Location}
• “Authorization Service / Server
Environment”:
• {Production, QA, Local}
• “Event cache”:
• {Production, QA, Local}
Product Flavors & Build Types & Build Variants
• Build Types
• Sets up various build properties.
• The debug build type enables debug options and signs
the APK with the debug key.
• The release build type may shrink, obfuscate, and sign
your APK with a release key for distribution.
• Android Studio creates the debug and release build
types by default.
• Product Flavors
• Product flavors represent different versions of your app
that you may release to users
• Free and paid versions of your app.
• You can customize product flavors to use different code
and resources, while sharing and reusing the parts that
are common to all versions of your app.
• Product flavors are optional and you must create them
manually.
• More info:
• https://developer.android.com/studio/build/index.html
• Build Variants
• The resulting entries in the set formed by cross-product
of BuildTypes x ProductFlavors
freeFlavor paidFlavor
debug freeDebug paidDebug
release freeRelease paidRelease
The Old Way
• “Build Type” did not propagate
to dependent modules
• Really old bug in Gradle
• Reported March, 2013
• https://issuetracker.google.com/issu
es/36967265
• “DESCRIPTION:
Gradle plugin does not propagate
whether you are doing a debug
build or a release build to a
dependent android library”
Agatha Build.conf:
buildTypes {
release {…}
debug {…}
simloc {…}
}
productFlavors {
prodFlavor {…}
qaFlavor {…}
devFlavor {…}
}
Dependencies{ …
simlocCompile project(path: ':common', configuration: 'simlocMongoQa')
debugCompile project(path: ':common', configuration: 'libraryMongoQa')
releaseCompile project(path: ':common', configuration: 'libraryMongoProd')}
Common Build.conf:
buildTypes {
mongoDev { … }
mongoQa { … }
mongoProd { … }
}
productFlavors {
library {
buildConfigField 'boolean', 'SIMLOC_BUILD', "false"
}
simloc {
buildConfigField 'boolean', 'SIMLOC_BUILD', "true"
}
}
Flavor Dimensions
• Flavor Dimensions add another
cross product.
• {A, B, C} ⋈ {D, E, F} ⋈ {Y, Z} =
• ADY, AEY, AFY
• BDY, BEY, BFY
• CDY, CEY, CFY
• ADZ, AEZ, AFZ
• BDZ, BEZ BFZ
• CDZ, CEZ, CFZ
• https://www.youtube.com/watc
h?v=daYl7edb6S0
Declaring Flavor Dimensions
• //Todo finish slide:
• https://developer.android.com/s
tudio/build/build-
variants.html#flavor-dimensions
The New Way Common: Build.conf
buildTypes {
debug{
debuggable true
buildConfigField 'boolean', 'SIMLOC_BUILD', "false"
}
release {
debuggable false
buildConfigField 'boolean', 'SIMLOC_BUILD', "false"
}
simloc {
debuggable true
buildConfigField 'boolean', 'SIMLOC_BUILD', "true"
}
}
flavorDimensions "mongo"
productFlavors {
mongoDevFlavor {
dimension "mongo"
buildConfigField 'String', 'DRIVE_EVENTREPL_URI', '”…"'
}
mongoQaFlavor {
dimension "mongo"
buildConfigField 'String', 'DRIVE_EVENTREPL_URI', '”…"'
}
mongoProdFlavor {
dimension "mongo"
buildConfigField 'String', 'DRIVE_EVENTREPL_URI', '"…"'
}
}
Agatha2: Build.conf
flavorDimensions "dsp", "mongo"
productFlavors {
prodFlavor {
dimension "dsp"
applicationId 'com.drivewyze.agatha2'
…
}
qaFlavor {
dimension "dsp"
applicationId 'com.drivewyze.agatha2.qa'
…
}
devFlavor {
dimension "dsp"
applicationId 'com.drivewyze.agatha2.dev'
…
}
mongoDevFlavor {
dimension "mongo"
}
mongoQaFlavor {
dimension "mongo"
}
mongoProdFlavor {
dimension "mongo"
}
}

More Related Content

What's hot (20)

PPTX
Android studio&Gradle&Autotest
毅 方
 
PDF
Intro to Gradle + How to get up to speed
Reid Baker
 
PDF
Mobile Day - Intel XDK & Testing
Software Guru
 
PDF
Get Your Node.js API Swaggering with OpenAPI Spec
Adam Paxton
 
PPTX
Swagger in the API Lifecycle
Ole Lensmar
 
PPTX
Android Studio vs Eclipse: What are the main differences?
avocarrot
 
PPTX
What's new in .net 5 by muralidharan deenathayalan
Muralidharan Deenathayalan
 
PDF
Drag and Drop UI Development with React Native
David Kay
 
PPTX
React Native
Fatih Şimşek
 
PPTX
Getting started with package management - Azure DevOps
Muralidharan Deenathayalan
 
PPTX
Capture the Cloud with Azure
Shahed Chowdhuri
 
PPTX
Swagger - make your API accessible
Victor Trakhtenberg
 
PDF
Introduction to React Native
Sambhu Lakshmanan
 
PDF
Android studio
Paresh Mayani
 
PDF
Experiences building apps with React Native @DomCode 2016
Adrian Philipp
 
PPTX
ASP.NET Core 1.0 Overview: Post-RC2
Shahed Chowdhuri
 
PDF
Optimizing React Native views for pre-animation
ModusJesus
 
PDF
A guide to hiring a great developer to build your first app (redacted version)
Oursky
 
PPTX
React Native Intro
Julia Vi
 
PDF
Docs Like Code
Anne Gentle
 
Android studio&Gradle&Autotest
毅 方
 
Intro to Gradle + How to get up to speed
Reid Baker
 
Mobile Day - Intel XDK & Testing
Software Guru
 
Get Your Node.js API Swaggering with OpenAPI Spec
Adam Paxton
 
Swagger in the API Lifecycle
Ole Lensmar
 
Android Studio vs Eclipse: What are the main differences?
avocarrot
 
What's new in .net 5 by muralidharan deenathayalan
Muralidharan Deenathayalan
 
Drag and Drop UI Development with React Native
David Kay
 
React Native
Fatih Şimşek
 
Getting started with package management - Azure DevOps
Muralidharan Deenathayalan
 
Capture the Cloud with Azure
Shahed Chowdhuri
 
Swagger - make your API accessible
Victor Trakhtenberg
 
Introduction to React Native
Sambhu Lakshmanan
 
Android studio
Paresh Mayani
 
Experiences building apps with React Native @DomCode 2016
Adrian Philipp
 
ASP.NET Core 1.0 Overview: Post-RC2
Shahed Chowdhuri
 
Optimizing React Native views for pre-animation
ModusJesus
 
A guide to hiring a great developer to build your first app (redacted version)
Oursky
 
React Native Intro
Julia Vi
 
Docs Like Code
Anne Gentle
 

Similar to Android Studio 3 - Dependency-Aware Build Variants and Product Flavors (20)

PPTX
Android studio build variants
Édipo Souza
 
PDF
Gradle 101
Kurt Mbanje
 
PPTX
Gradle build capabilities
Zeinab Mohamed Abdelmawla
 
PDF
Gradle-based Android Build System
moallemi
 
PDF
A Gradle Story
Eduardo Felipe Ewert Bonet
 
PPTX
Build your android app with gradle
Swain Loda
 
PDF
Building android apps with Gradle (GREACH 2015)
René Gröschke
 
PDF
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
Dicoding
 
PPTX
20160915 automation with_gradle
Yuki Nanri
 
PDF
Understanding Android Build Variants
donnfelker
 
PDF
Gradle presentation
Oriol Jiménez
 
PDF
Android : Deep dive into developing MobileApp using Android
Emertxe Information Technologies Pvt Ltd
 
PPTX
Gradle and Android Studio : Best of Friends
Romin Irani
 
PPTX
Android, Gradle & Dependecies
Édipo Souza
 
PDF
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Somkiat Khitwongwattana
 
PDF
Michal Havryluk: How To Speed Up Android Gradle Builds
mdevtalk
 
PDF
Gradle enabled android project
Shaka Huang
 
PDF
Gradle and Your Android Wearable Projects
CommonsWare
 
PDF
3 Tips to Help You Migrate to Android Studio 3.0
SafeDK
 
PPTX
Gradle,the new build system for android
zhang ghui
 
Android studio build variants
Édipo Souza
 
Gradle 101
Kurt Mbanje
 
Gradle build capabilities
Zeinab Mohamed Abdelmawla
 
Gradle-based Android Build System
moallemi
 
Build your android app with gradle
Swain Loda
 
Building android apps with Gradle (GREACH 2015)
René Gröschke
 
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
Dicoding
 
20160915 automation with_gradle
Yuki Nanri
 
Understanding Android Build Variants
donnfelker
 
Gradle presentation
Oriol Jiménez
 
Android : Deep dive into developing MobileApp using Android
Emertxe Information Technologies Pvt Ltd
 
Gradle and Android Studio : Best of Friends
Romin Irani
 
Android, Gradle & Dependecies
Édipo Souza
 
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Somkiat Khitwongwattana
 
Michal Havryluk: How To Speed Up Android Gradle Builds
mdevtalk
 
Gradle enabled android project
Shaka Huang
 
Gradle and Your Android Wearable Projects
CommonsWare
 
3 Tips to Help You Migrate to Android Studio 3.0
SafeDK
 
Gradle,the new build system for android
zhang ghui
 
Ad

Recently uploaded (20)

PDF
Rewards and Recognition (2).pdf
ethan Talor
 
PPTX
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
PDF
Power BI vs Tableau vs Looker - Which BI Tool is Right for You?
MagnusMinds IT Solution LLP
 
PPTX
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
PDF
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
PDF
Transparency into Your Software’s True Reach
team-WIBU
 
PPTX
WYSIWYG Web Builder Crack 2025 – Free Download Full Version with License Key
HyperPc soft
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
PPTX
Mistakes to Avoid When Selecting Policy Management Software
Insurance Tech Services
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 41
utfefguu
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PDF
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
PDF
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
PPTX
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
PPTX
IObit Uninstaller Pro 14.3.1.8 Crack Free Download 2025
sdfger qwerty
 
PDF
WholeClear Split vCard Software for Split large vCard file
markwillsonmw004
 
PPTX
Cubase Pro Crack 2025 – Free Download Full Version with Activation Key
HyperPc soft
 
PDF
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
Rewards and Recognition (2).pdf
ethan Talor
 
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
Power BI vs Tableau vs Looker - Which BI Tool is Right for You?
MagnusMinds IT Solution LLP
 
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
Transparency into Your Software’s True Reach
team-WIBU
 
WYSIWYG Web Builder Crack 2025 – Free Download Full Version with License Key
HyperPc soft
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
Mistakes to Avoid When Selecting Policy Management Software
Insurance Tech Services
 
IDM Crack with Internet Download Manager 6.42 Build 41
utfefguu
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
IObit Uninstaller Pro 14.3.1.8 Crack Free Download 2025
sdfger qwerty
 
WholeClear Split vCard Software for Split large vCard file
markwillsonmw004
 
Cubase Pro Crack 2025 – Free Download Full Version with Activation Key
HyperPc soft
 
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
Ad

Android Studio 3 - Dependency-Aware Build Variants and Product Flavors

  • 1. Dependency-Aware Build Variants in Android Studio 3.0 Stefan Martynkiw
  • 2. Android Studio 3.0 Introduction • Introduced at Google I/O 2017 • Improvements: • Faster Gradle build times • Profiling tools • UI • Network Request Inspection (with Retrofit & OkHTTP) • Device File Explorer • App-Private files too! (no more adb run-as!) • Android Gradle Plugin Improvements
  • 3. Application Structure and Dependencies • Applications in Android Studio can be structured into modules • Drivewyze Example: • Agatha (Mobile app) • Gaby (Stripped down for Android ELDs) • Erica (Stripped down for even older Android ELDs) • Common • “Magic Sauce” Agatha Erica Gaby Common
  • 4. Why have variants? • Production • Signing Keys, Production Environment • QA • Unsigned, QA test environment • Development • Unsigned, Local-host server Agatha Erica Gaby Common
  • 5. Set Theory and the Cross Product • {A, B, C} • {A, B, C} ⋈ {D, E, F} = • AD, AE, AF • BD, BE, BF • CD, CE, CF • {A, B, C} ⋈ {D, E, F} ⋈ {Y, Z} = • ADY, AEY, AFY • BDY, BEY, BFY • CDY, CEY, CFY • ADZ, AEZ, AFZ • BDZ, BEZ BFZ • CDZ, CEZ, CFZ
  • 6. Abstract  Real • “Build type”: • {Debug, Release, Simulated Location} • “Authorization Service / Server Environment”: • {Production, QA, Local} • “Event cache”: • {Production, QA, Local}
  • 7. Product Flavors & Build Types & Build Variants • Build Types • Sets up various build properties. • The debug build type enables debug options and signs the APK with the debug key. • The release build type may shrink, obfuscate, and sign your APK with a release key for distribution. • Android Studio creates the debug and release build types by default. • Product Flavors • Product flavors represent different versions of your app that you may release to users • Free and paid versions of your app. • You can customize product flavors to use different code and resources, while sharing and reusing the parts that are common to all versions of your app. • Product flavors are optional and you must create them manually. • More info: • https://developer.android.com/studio/build/index.html • Build Variants • The resulting entries in the set formed by cross-product of BuildTypes x ProductFlavors freeFlavor paidFlavor debug freeDebug paidDebug release freeRelease paidRelease
  • 8. The Old Way • “Build Type” did not propagate to dependent modules • Really old bug in Gradle • Reported March, 2013 • https://issuetracker.google.com/issu es/36967265 • “DESCRIPTION: Gradle plugin does not propagate whether you are doing a debug build or a release build to a dependent android library” Agatha Build.conf: buildTypes { release {…} debug {…} simloc {…} } productFlavors { prodFlavor {…} qaFlavor {…} devFlavor {…} } Dependencies{ … simlocCompile project(path: ':common', configuration: 'simlocMongoQa') debugCompile project(path: ':common', configuration: 'libraryMongoQa') releaseCompile project(path: ':common', configuration: 'libraryMongoProd')} Common Build.conf: buildTypes { mongoDev { … } mongoQa { … } mongoProd { … } } productFlavors { library { buildConfigField 'boolean', 'SIMLOC_BUILD', "false" } simloc { buildConfigField 'boolean', 'SIMLOC_BUILD', "true" } }
  • 9. Flavor Dimensions • Flavor Dimensions add another cross product. • {A, B, C} ⋈ {D, E, F} ⋈ {Y, Z} = • ADY, AEY, AFY • BDY, BEY, BFY • CDY, CEY, CFY • ADZ, AEZ, AFZ • BDZ, BEZ BFZ • CDZ, CEZ, CFZ • https://www.youtube.com/watc h?v=daYl7edb6S0
  • 10. Declaring Flavor Dimensions • //Todo finish slide: • https://developer.android.com/s tudio/build/build- variants.html#flavor-dimensions
  • 11. The New Way Common: Build.conf buildTypes { debug{ debuggable true buildConfigField 'boolean', 'SIMLOC_BUILD', "false" } release { debuggable false buildConfigField 'boolean', 'SIMLOC_BUILD', "false" } simloc { debuggable true buildConfigField 'boolean', 'SIMLOC_BUILD', "true" } } flavorDimensions "mongo" productFlavors { mongoDevFlavor { dimension "mongo" buildConfigField 'String', 'DRIVE_EVENTREPL_URI', '”…"' } mongoQaFlavor { dimension "mongo" buildConfigField 'String', 'DRIVE_EVENTREPL_URI', '”…"' } mongoProdFlavor { dimension "mongo" buildConfigField 'String', 'DRIVE_EVENTREPL_URI', '"…"' } } Agatha2: Build.conf flavorDimensions "dsp", "mongo" productFlavors { prodFlavor { dimension "dsp" applicationId 'com.drivewyze.agatha2' … } qaFlavor { dimension "dsp" applicationId 'com.drivewyze.agatha2.qa' … } devFlavor { dimension "dsp" applicationId 'com.drivewyze.agatha2.dev' … } mongoDevFlavor { dimension "mongo" } mongoQaFlavor { dimension "mongo" } mongoProdFlavor { dimension "mongo" } }