Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Dynamic feature moduleの基本 / Cookpad.apk #2
Search
star_zero
February 18, 2019
Programming
6.9k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Dynamic feature moduleの基本 / Cookpad.apk #2
star_zero
February 18, 2019
More Decks by star_zero
See All by star_zero
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1.7k
Jetpack Compose の Side-effect を使いこなす / DroidKaigi 2023
star_zero
5
7.3k
Android 14 新機能 / Android 14 Meetup Nagoya
star_zero
1
710
Android 14 と Predictive back gesture / Shibuya.apk #42
star_zero
0
520
Coroutines Test 入門 / Android Test Night #8
star_zero
2
1.4k
What's new in Jetpack / I/O Extended Japan 2022
star_zero
1
740
Kotlin 2021 Recap / DevFest 2021
star_zero
3
1.4k
Kotlin Symbol Processing (KSP) を使ったコード生成 / DroidKaigi 2021
star_zero
2
5.3k
What's new Android 12
star_zero
0
640
Other Decks in Programming
See All in Programming
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
330
Event is what happens
moro
2
3.7k
Spec-driven Development with AI
simas
PRO
0
2.3k
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
180
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
530
AI時代のシニアエンジニアとは
yosuke_furukawa
PRO
14
11k
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
1.6k
Inertia Rails: The One-Person Framework with React & Friends
skryukov
0
380
SODA - FACT BOOK(JP)
sodainc
1
40k
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
190
GraphQL の onError と Nullability のこれから
quramy
0
210
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
170
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Paper Plane
katiecoart
PRO
5
55k
GraphQLとの向き合い方2022年版
quramy
50
15k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
A designer walks into a library…
pauljervisheath
211
25k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
830
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
390
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.7k
Done Done
chrislema
187
17k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
600
Transcript
Dynamic feature module の基本 Cookpad.apk #2
About me •Kenji Abe •メディアプロダクト開発部 •Android cookpadTV •Twitter: @STAR_ZERO
Dynamic feature module (DFM)
概要 •Android App Bundle(aab)の機能 •アプリインストール後に特定のモジュールを 後からインストール ‣ インストール時のファイルサイズ削減 ‣ インストール時に含めることもできる
参考アプリ •Google Santa Tracker
⚠ 注意 ⚠ •まだ、Beta •製品版として公開するときはBeta Programに参加する 必要がある ‣ https://support.google.com/googleplay/android- developer/answer/9006925#beta
• (反映されるまで1-2週間かかる)
DFMをつくる
DFMをつくる •File -> New -> New Module -> Dynamic Feature
Module
DFMをつくる
DFMをつくる •Enable on-demand ‣ 動的配信をするかどうか •Fusing ‣ サポートされてない端末(4.4以下)でインストールさせるか ‣ Enable
on-demandにチェックがあるときのみ
DFMをつくる •Module title ‣ モジュール名 ‣ ダウンロード確認ダイアログで 使用される ‣ (10M超えると確認が必要)
DFMの中身
DFM/AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:dist="http://schemas.android.com/apk/distribution" package="com.star_zero.sample.dfm.feature1"> <dist:module dist:instant="false" dist:onDemand="true" dist:title="@string/title_feature1"> <dist:fusing
dist:include="true" /> </dist:module> </manifest>
DFM/build.gradle apply plugin: 'com.android.dynamic-feature' android { compileSdkVersion 28 defaultConfig {
minSdkVersion 21 targetSdkVersion 28 } } dependencies { implementation project(':app') implementation project(':core') }
app/build.gradle apply plugin: 'com.android.application' android { // ... dynamicFeatures =
[":feature_one", "feature_two"] } dependencies { implementation project(':core') }
モジュールの依存関係
•よくあるマルチモジュールの依存関係 モジュールの依存関係 feature_one feature_two app implementation project(':feature_one') implementation project(':feature_two')
•DFMの依存関係 モジュールの依存関係 feature_one feature_two app dynamicFeatures = [":feature_one", “feature_two"] implementation
project(':app') implementation project(':app')
Dynamic Delivery
Dynamic Delivery •動的にモジュールをダウンロード •com.google.android.play:core •https://developer.android.com/guide/app-bundle/ playcore
Dynamic Delivery val manager = SplitInstallManagerFactory.create(this) if (manager.installedModules.contains(MODULE_NAME)) { //
インストール済み return } val request = SplitInstallRequest.newBuilder() .addModule(MODULE_NAME) .build() manager.startInstall(request)
Dynamic Delivery val listener = SplitInstallStateUpdatedListener { state -> when
(state.status()) { // ... SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION -> { // ダウロード確認ダイアログを表示 startIntentSender( state.resolutionIntent()?.intentSender, null, 0, 0, 0) } } } // 登録 manager.registerListener(listener) // 登録解除 manager.unregisterListener(listener)
Dynamic Delivery •モジュールダウンロード後にアクセスするには SplitCompat Libraryが必要 <application … android:name="com.google.android.play.core.splitcompat.SplitCompatApplication"> </application> class
FeatureActivity : AppCompatActivity() { override fun attachBaseContext(newBase: Context?) { super.attachBaseContext(newBase) SplitCompat.install(this) } }
Dynamic Delivery •テストがしにくい ‣ デバッグ実行ではモジュールのダウンロードができない ‣ PlayConsoleの内部テストが必要
実装時のポイント
実装時のポイント •app側からfeatureモジュールは直接参照できない ‣ 参照するにはリフレクションを使う ‣ DIは工夫が必要 (dagger.androidは使わないほうが良いかも)
実装時のポイント •共通処理はcoreモジュールを作っておくと良い ‣ build.gradleでは api でライブラリを追加 ‣ APIアクセスや共通のDI Component ‣
DataBinding (共通の@BindingAdapterなど)
•coreモジュール 実装時のポイント feature_one app core
デバッグ実行
デバッグ実行 •Run -> Edit Configurations…
bundletool
bundletool •aabからapkを作ってくれる •オプションの指定で、モジュールをすべて含んだapkを 作成できる ‣ DeployGate等でapkを配布したい場合など •https://developer.android.com/studio/command- line/bundletool
bundletool $ bundletool build-apks \ --bundle=app.aab \ --output=app.apks \ --ks=release.keystore
\ --ks-pass=pass:sample \ --ks-key-alias=sample \ --key-pass=pass:sample \ --mode=universal # モジュールをすべて含めるオプション $ unzip app.apks # universal.apkが作られる ※universalは <dist:fusing dist:include=“false”/> は含めない
まとめ
まとめ •ダウンロードサイズ削減できる ‣ aab自体でも効果的 ‣ DFMによって更に削減できる •マルチモジュールの手法と捉えられる ‣ ビルド時間短縮 ‣
モジュール分割による設計
まとめ •テストがやりにくい ‣ PlayConsoleの内部テストが必要 •まだまだハマりどころ(バグ?)が多い ‣ DataBinding、Proguard/R8 ‣ 結局やってみないと分からないので色々試す
参考 •https://developer.android.com/studio/projects/dynamic- delivery •https://developer.android.com/guide/app-bundle/playcore •https://github.com/nickbutcher/plaid •https://medium.com/androiddevelopers/google-santa-tracker- moving-to-an-android-app-bundle-dde180716096 •https://www.youtube.com/watch?v=QdoEcfibG-s
ありがとうございました