Everything They Don't Tell You About Instant Apps

Everything They Don't Tell You About Instant Apps

Creating an Android project that is decoupled enough to be able to release an individual feature as an instant app is a tough ask. It becomes even more daunting when your starting point is a monolithic, single module project. In this talk we’ll go over how the Cricket World Cup 2019 app went from a 56MB APK to a 16MB app bundle + 4MB instant app, and we’ll show every single problem we hit along the way.

A2847e7d5f4cf8935b8829f4c1a32cec?s=128

Jamie Adkins

January 21, 2020
Tweet

Transcript

  1. Everything they don’t tell you about Instant Apps

  2. Cricket World Cup 2019

  3. CWC19 Quiz Instant App • ツ •

  4. Cricket World Cup 2019

  5. Dynamic Features

  6. What are Dynamic Features? • At Install Time ◦ •

    Conditional ◦ • Instant enabled ◦ • On Demand ◦
  7. What are Dynamic Features? • At Install Time ◦ •

    Conditional ◦ • Instant enabled ◦ Download just this feature when the user clicks on a link. • On Demand ◦
  8. Android Module Structure

  9. Dynamic Feature Modules

  10. Where We Started

  11. Where We Started

  12. Create a New Application Module

  13. Install From the Play Store

  14. Instant App Install

  15. 4MB Download Limit

  16. 4MB • • • ◦ • • • • •

    Total - 3.95MB
  17. Dependency Injection

  18. Dependency Injection

  19. Application Class - Before class IccApplication : DaggerApplication() { override

    fun onCreate() { super.onCreate() Timber.plant(CrashlyticsTree()) Fabric.with(this, Crashlytics()) } override fun applicationInjector() : AndroidInjector<out DaggerApplication> { return DaggerAppComponent.builder().create(this) } }
  20. Application Class - Before class IccApplication : DaggerApplication() { override

    fun onCreate() { super.onCreate() Timber.plant(CrashlyticsTree()) Fabric.with(this, Crashlytics()) } override fun applicationInjector() : AndroidInjector<out DaggerApplication> { return DaggerAppComponent.builder().create(this) } }
  21. Application Class - Before class IccApplication : DaggerApplication() { override

    fun onCreate() { super.onCreate() Timber.plant(CrashlyticsTree()) Fabric.with(this, Crashlytics()) } override fun applicationInjector() : AndroidInjector<out DaggerApplication> { return DaggerAppComponent.builder().create(this) } }
  22. Conclusions • • •

  23. Proposal • • • •

  24. None
  25. Android Manifest Merging

  26. Manifest Merging <activity android:name="com.icccricket.quiz.QuizActivity" android:theme="@style/QuizTheme">

  27. Manifest Merging <activity android:name="com.icccricket.quiz.QuizActivity" android:theme="@style/QuizTheme">

  28. Manifest Merging <activity android:name="com.icccricket.quiz.QuizActivity" android:theme="@style/QuizTheme">

  29. Manifest Merging <activity android:name="com.icccricket.quiz.QuizActivity" android:theme="@style/QuizTheme"> • ◦ ◦ •

  30. Stub Themes <!-- base/src/main/res/values/styles.xml --> <!-- Empty theme in base

    module --> <style name=”QuizTheme” />
  31. Stub Themes <!-- base/src/main/res/values/styles.xml --> <!-- Empty theme in base

    module --> <style name=”QuizTheme” /> <!-- quiz/src/main/res/values/styles.xml --> <!-- Actual implementation in quiz dynamic feature module --> <style name="QuizTheme" parent="Theme.MaterialComponents"> <item name="colorPrimary">@color/cwc_primary</item> <item name="colorAccent">@color/cwc_secondary</item> ...
  32. Stub Themes Caveats • ◦ ◦ ◦ •

  33. Making Every Feature a Dynamic Feature

  34. Resist the Urge!

  35. Quick Fire Tips

  36. Quick Fire Tips • • •

  37. Further Reading • • •