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.2k
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
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
170
1B+ /day規模のログを管理する技術
broadleaf
0
140
Foundation Models frameworkで画像分析
ryodeveloper
1
120
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
170
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
500
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
860
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
140
コーディングルールの鮮度を保ちたい for SRE NEXT 2026 / keep-fresh-go-internal-conventions-sre-next-2026
handlename
0
140
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
180
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
0
210
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
190
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
810
Writing Fast Ruby
sferik
630
63k
Optimizing for Happiness
mojombo
378
71k
New Earth Scene 8
popppiees
3
2.4k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
2
340
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
660
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
410
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
390
Bash Introduction
62gerente
615
220k
KATA
mclloyd
PRO
35
15k
Site-Speed That Sticks
csswizardry
13
1.3k
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?