Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ben Weiss - Migrating_from_installed_to_instant...

Ben Weiss - Migrating_from_installed_to_instant_app - a_retrospective

droidcon Berlin

July 17, 2018
Tweet

More Decks by droidcon Berlin

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. Topeka | TODO Size < 4MB Not URL addressable Manual

    login ⤫ ⤫ ⤫ DroidCon Berlin - 2018
  4. 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
  5. Topeka | TODO Not URL addressable Manual login ⤫ ⤫

    ✓ Size < 4MB ⤫ DroidCon Berlin - 2018
  6. <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
  7. 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
  8. 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
  9. Topeka | TODO Not URL addressable Manual login ⤫ ✓

    ✓ Size < 4MB ⤫ DroidCon Berlin - 2018
  10. Topeka | TODO Not URL addressable Manual login ✓ ✓

    Size < 4MB ⤫ DroidCon Berlin - 2018
  11. Feature module shuffle | base Shared code • Included dependencies

    ◦ api • Utilities • Model • Data layer DroidCon Berlin - 2018
  12. Feature module shuffle | base Shared resources • colors •

    themes • styles • drawables • strings • transitions DroidCon Berlin - 2018
  13. 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
  14. Feature module shuffle | others • Controllers • UI (custom

    views) • Tests • Separate AndroidManifest • Drawables / assets • Package name changes DroidCon Berlin - 2018
  15. Topeka | TODO Not URL addressable Manual login ✓ ✓

    Size < 4MB ⤫ DroidCon Berlin - 2018
  16. 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
  17. 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
  18. build.gradle: // feature modules productFlavors { ... instant { dimension

    'delivery' minSdkVersion rootProject.minSdkInstant } } DroidCon Berlin - 2018
  19. Topeka | TODO Not URL addressable Manual login ✓ ✓

    ✓ Size < 4MB ⤫ DroidCon Berlin - 2018
  20. Takeaways Prerequisites first URLs, SmartLock, Restricted APIs, Permissions Refactor one

    feature at a time Apply new plugins Size constraints DroidCon Berlin - 2018
  21. Next Steps Link to domain using Android App Links Upload

    to the Play Store Android App Bundle & Dynamic Delivery DroidCon Berlin - 2018
  22. 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
  23. 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
  24. shared search bypass DroidCon Berlin - 2018 com.android.library about designer

    news dribbble app com.android.application com.android.dynamic-feature
  25. Google Play Core API Enables dynamic delivery through the Google

    Play Store Request modules Delete modules Immediately or deferred DroidCon Berlin - 2018
  26. PlayCore API: Set up override fun onCreate(savedInstanceState: Bundle?) { ...

    manager = SplitInstallManagerFactory.create(this) btn.setOnClickListener { install("dribbble") } } DroidCon Berlin - 2018
  27. PlayCore API: Handle modules that are already installed fun install(moduleName:

    String) { if (manager.installedModules .contains(moduleName)) { onSuccessfulLoad(name) return } ... DroidCon Berlin - 2018
  28. PlayCore API: Handle results private fun onSuccessfulLoad(moduleName: String) { ...

    Intent().setClassName(packageName, className) .also { startActivity(it) } ... } DroidCon Berlin - 2018
  29. Optimized APK for each device Upload an Android App Bundle

    Dynamic Delivery by Google Play DroidCon Berlin - 2018
  30. 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