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
Modularizing your Android App
Search
Himanshu Singh
October 12, 2019
Technology
0
280
Modularizing your Android App
This PPT is about Modularising your Android App using dynamic delivery.
Himanshu Singh
October 12, 2019
Tweet
Share
More Decks by Himanshu Singh
See All by Himanshu Singh
Debugging as a Skill
himanshoe
0
27
Elevating your App’s performance
himanshoe
0
36
FOMO in Android
himanshoe
1
820
Composing your Canvas : DroidCon
himanshoe
2
410
Composing in your Canvas
himanshoe
0
130
Backend Engineering for Android Developers
himanshoe
0
510
Mastering CameraX API
himanshoe
0
170
kotlin.pdf
himanshoe
0
80
Golang.pdf
himanshoe
0
160
Other Decks in Technology
See All in Technology
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
280
非機能品質を作り込むための実践アーキテクチャ
knih
5
1.6k
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
280
UI State設計とテスト方針
rmakiyama
2
740
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
190
Wantedly での Datadog 活用事例
bgpat
1
580
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
1
230
3年でバックエンドエンジニアが5倍に増えても破綻しなかったアーキテクチャ そして、これから / Software architecture that scales even with a 5x increase in backend engineers in 3 years
euglena1215
7
1.5k
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
250
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
270
どちらを使う?GitHub or Azure DevOps Ver. 24H2
kkamegawa
0
1k
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
3
1.4k
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Navigating Team Friction
lara
183
15k
Facilitating Awesome Meetings
lara
50
6.1k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Bash Introduction
62gerente
609
210k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Documentation Writing (for coders)
carmenintech
66
4.5k
Transcript
Himanshu Singh @hi_man_shoe Modularizing your Android App
Himanshu Singh @hi_man_shoe About Me? Sr Android Engineer @roomiapp Instructor
and open source contributor @ Mindorks.com
Android Developers ?
Android Developers ?
Let’s Talk about the problem
Let’s Talk about the problem ચાલો શરૂ કરીએ ?
None
Module Bug Release Android Development Graph Feature
Solution to this ??
Multi - Modules
What and Whys of Multi Modules
Let’s talk about What
Let’s Talk about What Why
None
Library Modules Dynamic Delivery Modules
Library Modules Dynamic Delivery Modules
Let’s start with the code
Let’s start with the code
Create an Android Project (App Module)
Create an Android Project (App Module)
None
Create an Android Project (App Module) Goto File-> New ->
New Module and select Dynamic Feature Module (>Kitkat)
None
On the next screen, you will get a few options
to configure your module.
On the next screen, you will get a few options
to configure your module.
Press Finish :)
Final Project Looks like :)
What we want to achieve ?
<RelativeLayout> <Button android:id="@+id/buttonClick"/> <Button android:id="@+id/buttonOpenNewsModule android:visibility="gone"/> <Button android:id="@+id/buttonDeleteNewsModule" android:visibility="gone"/> </RelativeLayout>
android { ....... dynamicFeatures = [":news_feature"] } In app’s build.gradle
file
apply plugin: 'com.android.dynamic-feature' dependencies { ..... implementation project(':app') } In
new_feature’s build.gradle file
<dist:module dist:instant="false" dist:onDemand="true" dist:title="@string/title_news_feature"> <dist:fusing dist:include="true"/> </dist:module> In the manifest
of the dynamic Module,
<dist:module dist:instant="false" dist:onDemand="true" dist:title="@string/title_news_feature"> <dist:fusing dist:include="true"/> </dist:module>
<dist:module dist:instant="false" dist:onDemand="true" dist:title="@string/title_news_feature"> <dist:fusing dist:include="true"/> </dist:module>
implementation 'com.google.android.play:core:1.6.3' To make your module downloadable on demand add
the following in the app-module's build.gradle,
Pro Tip #1 • Treat the dynamic-module as the individual
app itself
dependencies { ..... api 'androidx.appcompat:appcompat:1.0.2' api 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.play:core:1.6.1' }
In the manifest of the app’s module,
This is our project
dependencies { ..... api 'androidx.appcompat:appcompat:1.0.2' api 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.play:core:1.6.1' }
In the manifest of the app’s module,
dependencies { ..... api 'androidx.appcompat:appcompat:1.0.2' api 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.play:core:1.6.1' }
In the manifest of the app’s module,
Let's learn how to make the dynamic-feature downloadable from the
app's module.
class MainActivity : AppCompatActivity() { lateinit var splitInstallManager: SplitInstallManager lateinit
var request: SplitInstallRequest val DYNAMIC_FEATURE = "news_feature" override fun onCreate(savedInstanceState: Bundle?) { .... } } In App’s MainActivity
override fun onCreate(savedInstanceState: Bundle) { .... initDynamicModules() } private fun
initDynamicModules() { splitInstallManager = SplitInstallManagerFactory.create(this) request = SplitInstallRequest .newBuilder() .addModule(DYNAMIC_FEATURE) .build(); } In App’s MainActivity
Implement Clicks :)
In App’s MainActivity override fun onCreate(savedInstanceState: Bundle) { ........ buttonClick.setOnClickListener
{ if (!isDynamicFeatureDownloaded(DYNAMIC_FEATURE)) { downloadFeature() } else { buttonDeleteNewsModule.visibility = View.VISIBLE buttonOpenNewsModule.visibility = View.VISIBLE } } }
In App’s MainActivity private fun isDynamicFeatureDownloaded(feature: String): Boolean = splitInstallManager.installedModules.contains(feature)
In App’s MainActivity private fun downloadFeature() { splitInstallManager.startInstall(request) .addOnFailureListener {
//on Failure Handle } .addOnSuccessListener { buttonOpenNewsModule.visibility = View.VISIBLE buttonDeleteNewsModule.visibility = View.VISIBLE } .addOnCompleteListener { } }
None
Let’s Open the News Activity
In App’s MainActivity buttonOpenNewsModule.setOnClickListener { val intent = Intent() .setClassName(this,
"com.mindorks.news_feature.newsloader.NewsLoaderActivity") startActivity(intent) }
In App’s MainActivity buttonOpenNewsModule.setOnClickListener { val intent = Intent() .setClassName(this,
"com.mindorks.news_feature.newsloader.NewsLoaderActivity") startActivity(intent) }
In App’s MainActivity buttonDeleteNewsModule.setOnClickListener { val list = listOf(DYNAMIC_FEATURE) splitInstallManager.deferredUninstall(list)
.addOnSuccessListener { buttonDeleteNewsModule.visibility = View.GONE buttonOpenNewsModule.visibility = View.GONE } }
Library Modules
Create an Android Project (App Module) Goto File -> New
-> New Module
None
And Use it how you use other libraries :)
Pro Tip #2 • Checkout Darshan’s Talk to understand this
module for the library creation
When ???
Library Modules Dynamic Delivery Modules
Library Modules Dynamic Delivery Modules
Why this approach ???
• Easily Manageable By Multiple Devs • Maintainability • Reduced
APK Size • Testing New Features
• Easily Manageable By Multiple Devs • Maintainability • Reduced
APK Size • Testing New Features
• Easily Manageable By Multiple Devs • Maintainability • Reduced
APK Size • Testing New Features
• Easily Manageable By Multiple Devs • Maintainability • Reduced
APK Size • Testing New Features
Link to project https://tiny.cc/gdgahm
Any Question? Himanshu Singh @hi_man_shoe
Thanks :) Himanshu Singh @hi_man_shoe