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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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駆動開発」紹介スライド
juntaromatsumoto
0
780
Dockerfile CMD for Node.js
grazie1999
0
140
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
220
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
650
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
120
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.2k
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
390
高専、大学編入、そして未踏へ〜プロダクト開発とキャリアの歩み - Technical College, University Transfer, and On to “Mitou” / My Journey in Product Development and Career
pkmiya
0
100
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
1
830
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
460
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
560
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.3k
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
510
WCS-LA-2024
lcolladotor
0
810
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
RailsConf 2023
tenderlove
30
1.5k
Discover your Explorer Soul
emna__ayadi
2
1.3k
My Coaching Mixtape
mlcsv
0
300
GraphQLとの向き合い方2022年版
quramy
50
15k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
400
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?