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
210
Dealing with Imposter Syndrome
physphil
4
95
What is Kotlin Serialization? (And should I use it?)
physphil
0
210
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
320
Grokking Android Studio
physphil
0
190
Download This! Tips for Successfully Promoting Your Android App
physphil
0
120
Android Networking (Without Going Crazy)
physphil
0
110
Other Decks in Programming
See All in Programming
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
170
不幸な GC
chencmd
0
810
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
730
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
420
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
0
360
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
160
Cloudflare is Agents
chimame
0
180
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
120
ALB ログから Trace を気合で繋げる技術
fohte
7
760
Go 1.27 における memory allocation の高速化
andpad
0
340
T3DD26: From RAGs to Riches
martinhelmich
0
110
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
220
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.8k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
450
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
210
Git: the NoSQL Database
bkeepers
PRO
432
67k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
500
The Cost Of JavaScript in 2023
addyosmani
55
10k
Abbi's Birthday
coloredviolet
3
9.5k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
What's in a price? How to price your products and services
michaelherold
247
13k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
670
We Are The Robots
honzajavorek
0
310
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?