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
Ben Weiss - Migrating_from_installed_to_instant...
Search
droidcon Berlin
July 17, 2018
Programming
0
76
Ben Weiss - Migrating_from_installed_to_instant_app - a_retrospective
droidcon Berlin
July 17, 2018
Tweet
Share
More Decks by droidcon Berlin
See All by droidcon Berlin
Jon Markoff - Best practice for apps
droidcon_berlin_2018
0
170
Jon Markoff - Voice in the enterprise
droidcon_berlin_2018
0
51
Michael Jess - Enabling enterprise mobility with SAP
droidcon_berlin_2018
0
87
Ronen Sabag - Lean async code with Kotlin’s coroutines
droidcon_berlin_2018
0
41
Boris Farber & Nikita Kozlov - The_Build_Side_of_Android_App
droidcon_berlin_2018
0
170
Zan Markan - The state of Kotlin
droidcon_berlin_2018
0
63
Miquel Beltran - No More □ (tofu) Mastering Emoji on Android
droidcon_berlin_2018
0
110
Laurent Gasser & Jeremy Rochot - Sharing a success story - A low cost, Customer driven and co-developed Android EMM
droidcon_berlin_2018
0
180
Hoi Lam - Adding ML Kit to Android Things And some TensorFlow things
droidcon_berlin_2018
1
170
Other Decks in Programming
See All in Programming
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
260
Macとオーディオ再生 2024/11/02
yusukeito
0
380
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
150
Jakarta EE meets AI
ivargrimstad
0
210
Outline View in SwiftUI
1024jp
1
340
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.8k
subpath importsで始めるモック生活
10tera
0
320
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
380
Optimising Largest Contentful Paint
csswizardry
33
2.9k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
What's in a price? How to price your products and services
michaelherold
243
12k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Statistics for Hackers
jakevdp
796
220k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Transcript
Installed → Instant A retrospective Ben Weiss @keyboardsurfer & Beyond
DroidCon Berlin - 2018
Google Play Instant DroidCon Berlin - 2018
Discovering an app DroidCon Berlin - 2018
Discovering an app Use Install Find DroidCon Berlin - 2018
With Google Play Instant DroidCon Berlin - 2018
> 1b devices DroidCon Berlin - 2018
Requirements DroidCon Berlin - 2018
Lollipop DroidCon Berlin - 2018
Android Studio 3.0+ • Instant Apps SDK • Gradle plugins
◦ com.android.feature ◦ com.android.instantapp • App Links Assistant • Emulator support • Refactoring tool DroidCon Berlin - 2018
4 MB < DroidCon Berlin - 2018
Migrating a real app DroidCon Berlin - 2018
Topeka DroidCon Berlin - 2018
A fun to play quiz Available on GitHub googlesamples/android-topeka Topeka
DroidCon Berlin - 2018
Topeka | UI DroidCon Berlin - 2018
Topeka | Development timeline now Sept 2014 First commit May
2015 Published to GitHub Transitions July 2015 Sept 2015 minSdkVersion 16 Oct 2015 minSdkVersion 14 Kotlin May 2017 DroidCon Berlin - 2018
Topeka | Now But how DroidCon Berlin - 2018
g.co/instantapps DroidCon Berlin - 2018
Topeka | TODO Size < 4MB Not URL addressable Manual
login ⤫ ⤫ ⤫ DroidCon Berlin - 2018
DroidCon Berlin - 2018
SmartLock API Automatically sign in users Less friction Faster access
to content DroidCon Berlin - 2018
SmartLock API Save Retrieve Activity Result DroidCon Berlin - 2018
CredentialsHelper.kt: fun Context.apiClient() = Credentials.getClient(this) apiClient().request() apiClient().save(playerCredentials) DroidCon Berlin -
2018
CredentialsHelper.kt: fun Activity.onSmartLockResult( requestCode: Int, resultCode: Int, data: Intent?, success:
(Player) -> Unit, failure: () -> Unit) DroidCon Berlin - 2018
CredentialsHelper.kt: fun Activity.requestLogin(success: (Player) -> Unit) fun Context.logout() DroidCon Berlin
- 2018
interface Login { fun loginPlayer(activity: Activity, onSuccess: (Player) -> Unit)
fun savePlayer(activity: Activity, player: Player, onSuccess: () -> Unit) } object DefaultLogin : Login // used within the app object TestLogin : Login // used for testing DroidCon Berlin - 2018
Topeka | TODO Not URL addressable Manual login ⤫ ⤫
✓ Size < 4MB ⤫ DroidCon Berlin - 2018
nytimes.com/crosswords URL Addressable DroidCon Berlin - 2018
<activity> <intent-filter android:autoVerify="true"> </intent-filter> </activity> <data android:scheme="http" /> <data android:scheme="https"
/> <data android:host="topeka.instantappsample.com" /> <data android:path="/signin" /> DroidCon Berlin - 2018
Intent(Action.VIEW, QuizActivity.class::java) .apply { putExtra(Category.TAG, category.id) val start = Intent(Intent.ACTION_VIEW,
myURL) .addCategory(Intent.CATEGORY_DEFAULT) .addCategory(Intent.CATEGORY_BROWSABLE) intent.`package` = context.packageName DroidCon Berlin - 2018
const val URL_BASE = "mybaseUrl" const val URL_SIGNIN = "$URL_BASE/signin"
const val URL_CATEGORIES = "$URL_BASE/categories" const val URL_QUIZ_BASE = "$URL_BASE/quiz/" // append category id DroidCon Berlin - 2018
Topeka | TODO Not URL addressable Manual login ⤫ ✓
✓ Size < 4MB ⤫ DroidCon Berlin - 2018
Gradle Plugins com.android.application DroidCon Berlin - 2018
Gradle Plugins com.android.instantapp DroidCon Berlin - 2018
Gradle Plugins com.android.feature application → aar instantapp → apk DroidCon
Berlin - 2018
app Create new modules settings.gradle: include ':base', ':installed', ':instant' base
instant installed apk aar DroidCon Berlin - 2018
Topeka | TODO Not URL addressable Manual login ✓ ✓
Size < 4MB ⤫ DroidCon Berlin - 2018
Feature module shuffle base quiz categories instant apk installed aar
DroidCon Berlin - 2018
s://commons.wikimedia.org/wiki/File:Spaghetti_al_Pomodoro.jpg
Feature module shuffle | base Shared code • Included dependencies
◦ api • Utilities • Model • Data layer DroidCon Berlin - 2018
Feature module shuffle | base Shared resources • colors •
themes • styles • drawables • strings • transitions DroidCon Berlin - 2018
Feature module shuffle | base Package name com.google.samples.apps.topeka.base.R as RBase
• Every dependent import has to change DroidCon Berlin - 2018 • Kotlin enables import aliasing
Feature module shuffle | others • Controllers • UI (custom
views) • Tests • Separate AndroidManifest • Drawables / assets • Package name changes DroidCon Berlin - 2018
Topeka | TODO Not URL addressable Manual login ✓ ✓
Size < 4MB ⤫ DroidCon Berlin - 2018
ConfigurationApks Screen Density User Language Processor Architecture DroidCon Berlin -
2018
ConfigurationApks res/ drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi drawable-xxxhdpi Base base.apk base-drawable-mdpi.apk
base-drawable-hdpi.apk base-drawable-xhdpi.apk base-drawable-xxhdpi.apk base-drawable-xxxhdpi.apk DroidCon Berlin - 2018
ConfigurationApks base.apk quiz.apk categories.apk instant.zip ldpi mdpi hdpi xhdpi xxhdpi
xxxhdpi ldpi mdpi hdpi xhdpi xxhdpi xxxhdpi ldpi mdpi hdpi xhdpi xxhdpi xxxhdpi DroidCon Berlin - 2018
build.gradle: // feature modules flavorDimensions 'delivery' DroidCon Berlin - 2018
build.gradle: // feature modules productFlavors { installed { dimension 'delivery'
} ... } DroidCon Berlin - 2018
build.gradle: // feature modules productFlavors { ... instant { dimension
'delivery' minSdkVersion rootProject.minSdkInstant } } DroidCon Berlin - 2018
build.gradle: // installed app module defaultConfig { missingDimensionStrategy 'delivery', 'installed'
} DroidCon Berlin - 2018
build.gradle: // instant app module defaultConfig { missingDimensionStrategy 'delivery', 'instant'
} DroidCon Berlin - 2018
Topeka | TODO Not URL addressable Manual login ✓ ✓
✓ Size < 4MB ⤫ DroidCon Berlin - 2018
Bonus Round | Proguard Keep API surfaces intact DroidCon Berlin
- 2018
Takeaways Prerequisites first URLs, SmartLock, Restricted APIs, Permissions Refactor one
feature at a time Apply new plugins Size constraints DroidCon Berlin - 2018
Next Steps Link to domain using Android App Links Upload
to the Play Store Android App Bundle & Dynamic Delivery DroidCon Berlin - 2018
DroidCon Berlin - 2018
DroidCon Berlin - 2018
DroidCon Berlin - 2018
DroidCon Berlin - 2018 g.co/androidappbundle
DroidCon Berlin - 2018 master.apk ch.apk de.apk en.apk es.apk it.apk
pl.apk x86.apk armeabi.apk mips.apk drawable-ldpi.apk drawable-hdpi.apk drawable-mdpi.apk drawable-xhdpi.apk drawable-xxxhdpi.apk drawable-xxhdpi.apk
DroidCon Berlin - 2018 de.apk x86.apk drawable-xxxhdpi.apk master.apk
DroidCon Berlin - 2018 aab 4.2 MB apk 8.6 MB
com.android.application com.android.library com.android.dynamic-feature Modular Development DroidCon Berlin - 2018
Modular Development Core com.android.application app -> HomeActivity & few resources
com.android.library base -> most shared code & resources external dependencies search -> search code & resources DroidCon Berlin - 2018
Modular Development Dynamic Feature Modules com.android.dynamic-feature Separable Activity & local
resources designernews dribbble about DroidCon Berlin - 2018
shared search bypass DroidCon Berlin - 2018 com.android.library about designer
news dribbble app com.android.application com.android.dynamic-feature
Google Play Core API Enables dynamic delivery through the Google
Play Store Request modules Delete modules Immediately or deferred DroidCon Berlin - 2018
PlayCore API: Set up override fun onCreate(savedInstanceState: Bundle?) { ...
manager = SplitInstallManagerFactory.create(this) btn.setOnClickListener { install("dribbble") } } DroidCon Berlin - 2018
PlayCore API: Handle modules that are already installed fun install(moduleName:
String) { if (manager.installedModules .contains(moduleName)) { onSuccessfulLoad(name) return } ... DroidCon Berlin - 2018
PlayCore API: Request installation ... val request = SplitInstallRequest.newBuilder() .addModule(moduleName)
.build() manager.startInstall(request) } DroidCon Berlin - 2018
PlayCore API: Handle results private fun onSuccessfulLoad(moduleName: String) { ...
Intent().setClassName(packageName, className) .also { startActivity(it) } ... } DroidCon Berlin - 2018
Optimized APK for each device Upload an Android App Bundle
DroidCon Berlin - 2018
Optimized APK for each device Upload an Android App Bundle
Dynamic Delivery by Google Play DroidCon Berlin - 2018
Takeaways You can release an .aab today faster delivery ==
happier users Map out before you modularize Dynamic Delivery can be added at any point But still: Work one feature at a time DroidCon Berlin - 2018
Source Code: github.com/googlesamples/android-topeka github.com/nickbutcher/plaid Samples: github.com/googlesamples/android-instant-apps github.com/googlesamples/android-dynamic-features Blog: Enabling ProGuard
in an Android Instant App Docs: g.co/InstantApps g.co/AndroidAppBundle Resources DroidCon Berlin - 2018
Thank you! Ben Weiss @keyboardsurfer DroidCon Berlin - 2018
Questions? Ben Weiss @keyboardsurfer DroidCon Berlin - 2018