Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Level Up with Android Build Variants
Search
Phil Shadlyn
July 07, 2015
Programming
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Level Up with Android Build Variants
Phil Shadlyn
July 07, 2015
More Decks by Phil Shadlyn
See All by Phil Shadlyn
Kotlin Sequences: Deep Dive
physphil
1
200
Dealing with Imposter Syndrome
physphil
4
90
What is Kotlin Serialization? (And should I use it?)
physphil
0
200
I Wrote an App with Architecture Components
physphil
6
1.1k
Android Auto - Drive Your Car, Use Your Phone, and Don't Hurt Anyone
physphil
0
310
Grokking Android Studio
physphil
0
190
Download This! Tips for Successfully Promoting Your Android App
physphil
0
110
Android Networking (Without Going Crazy)
physphil
0
110
Other Decks in Programming
See All in Programming
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
310
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
220
AI時代、エンジニアはどう育つのか -未経験エンジニアの成長を間近で見て考えたこと-
thasu0123
0
110
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
110
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.8k
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
180
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
400
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
110
Contextとはなにか
chiroruxx
1
390
共通化で考えるべきは、実装より公開する型だった
codeegg
0
210
OSINT for SRE: 学術論文とポストモーテムから探る システム障害の共通パターン / SRE NEXT 2026
tomoyk
1
3.5k
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.4k
Featured
See All Featured
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Embracing the Ebb and Flow
colly
88
5.1k
KATA
mclloyd
PRO
35
15k
Claude Code のすすめ
schroneko
67
230k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
220
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.7k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
650
GraphQLとの向き合い方2022年版
quramy
50
15k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
260
The Curious Case for Waylosing
cassininazir
1
430
Google's AI Overviews - The New Search
badams
0
1.1k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
190
Transcript
Level Up with Android Build Variants
Why do I care? • It’d be nice to build
multiple variants of an Android app from a single code base • Common variants include: ◦ debug/release ◦ free/paid ◦ dev/staging/production
With Eclipse and Ant • Code base contained in library
project • Needed an additional project for each variant which referenced library project
None
With Android Studio and Gradle • All contained in single
project • Define Build Types and Product Flavours in build.gradle file • Create src directories to hold code specific to each build type/flavour
None
Build Types • Define how to build and package your
app • debug and release build types created by default • Can create your own
signingConfigs { release { storeFile file( 'release.keystore' ) storePassword 'verysecurepassw0rd'
keyAlias 'release' keyPassword 'verysecurepassw0rd' } } buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile( 'proguard-android.txt' ), 'proguard-rules.pro' signingConfig signingConfigs.release } debug{ applicationIdSuffix ".debug" signingConfig null } }
Product Flavours • Provide alternative code, resources or configuration •
Examples: ◦ Different API endpoints for dev/staging/production environment ◦ Free/paid version
Free / Paid • Provide alternative resources and code by
creating flavour directory • Gradle creates combination of each Build Type and Product Flavour
productFlavors{ free{ applicationId "com.physphil.android.sandbox.free" } paid{ applicationId "com.physphil.android.sandbox.pro" } }
} dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.1' compile 'de.greenrobot:eventbus:2.4.0' // Only full version requires network calls paidCompile 'com.squareup.retrofit:retrofit:1.9.0' paidCompile 'com.squareup.okhttp:okhttp:2.2.0' }
None
Free / Paid
Dev / Staging / Production • Define flavour for each
server environment • Store API base URL in a Config class • Create directory in src for each flavour, which contains an instance of Config
buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile(
'proguard-android.txt' ), 'proguard-rules.pro' signingConfig signingConfigs.release } debug { applicationIdSuffix ".debug" signingConfig null } } productFlavors { dev staging production }
None
That’s Not All! • Modify more build parameters • Include
libraries, code, Activities etc only when required • Lots of examples in official docs
Additional Resources • http://tools.android.com/tech-docs/new-build- system/user-guide • https://developer.android. com/tools/building/configuring-gradle.html • http://www.vogella.
com/tutorials/AndroidBuild/article.html
Questions?