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
22
Elevating your App’s performance
himanshoe
0
32
FOMO in Android
himanshoe
1
810
Composing your Canvas : DroidCon
himanshoe
2
410
Composing in your Canvas
himanshoe
0
120
Backend Engineering for Android Developers
himanshoe
0
500
Mastering CameraX API
himanshoe
0
170
kotlin.pdf
himanshoe
0
77
Golang.pdf
himanshoe
0
160
Other Decks in Technology
See All in Technology
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
190
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
360
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
[FOSS4G 2019 Niigata] AIによる効率的危険斜面抽出システムの開発について
nssv
0
310
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
470
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
510
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
280
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
170
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
Featured
See All Featured
A Philosophy of Restraint
colly
203
16k
Practical Orchestrator
shlominoach
186
10k
Building Adaptive Systems
keathley
38
2.3k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Designing Experiences People Love
moore
138
23k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Music & Morning Musume
bryan
46
6.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
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