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

Droidcon London: Preparing your app for Google Play Instant

Droidcon London: Preparing your app for Google Play Instant

Android Instant applications are becoming increasingly available, and thanks to the work from the Android platform team can already be installed on devices running Android Lollipop or later.

As an application developer for a large application, or one with plenty of untested legacy code, preparing an application that might be tightly coupled into a single module requires us to carefully de-tangle and move concerns to independent modules.

This talk covers how we managed to prepare our application for instant apps by breaking off base elements and isolating essential key features into self-contained, independent modules, with all the difficulties that this entails and how you can avoid the common pain points and pitfalls.

Ash Davies

October 26, 2018
Tweet

More Decks by Ash Davies

Other Decks in Programming

Transcript

  1. Preparing your app for Google Play Instant
    Droidcon London 2018
    ashdavies.io - @askashdavies

    View Slide

  2. View Slide

  3. View Slide

  4. View Slide

  5. !

    View Slide

  6. View Slide

  7. !
    Friction

    View Slide

  8. View Slide

  9. View Slide

  10. !

    View Slide

  11. < />

    View Slide

  12. View Slide

  13. View Slide

  14. Lollipop

    View Slide

  15. View Slide


  16. View Slide

  17. Try Now

    View Slide


  18. android:name="default-url"
    android:value="https://example.com/welcome" />

    View Slide

  19. Performance

    View Slide

  20. Security

    View Slide

  21. !
    HTTPS

    View Slide

  22. Smart Lock

    View Slide

  23. Auth.CredentialsApi.save(mCredentialsClient, credential).setResultCallback(
    new ResultCallback() {
    @Override
    public void onResult(Status status) {
    if (status.isSuccess()) {
    // Credentials were saved
    } else {
    if (status.hasResolution()) {
    // Try to resolve the save request. This will prompt the user if
    // the credential is new.
    try {
    status.startResolutionForResult(this, RC_SAVE);
    } catch (IntentSender.SendIntentException e) {
    // Could not resolve the request
    }
    }
    }
    }
    });

    View Slide

  24. !
    Play Billing Library

    View Slide

  25. !
    Runtime Permissions

    View Slide

  26. • ACCESS_COARSE_LOCATION
    • ACCESS_FINE_LOCATION
    • ACCESS_NETWORK_STATE
    • BILLING (Deprecated as of Play Billing Library 1.0)
    • CAMERA
    • INSTANT_APP_FOREGROUND_SERVICE (Only in Android Oreo)
    • INTERNET
    • READ_PHONE_NUMBERS (Only in Android Oreo)
    • RECORD_AUDIO
    • VIBRATE

    View Slide

  27. Limitations

    View Slide

  28. ! ⛏

    View Slide

  29. Background Services

    View Slide

  30. Push Notifications

    View Slide

  31. External Storage

    View Slide

  32. !
    Local Storage

    View Slide

  33. Instant <-> Installed

    View Slide

  34. Cookie API

    View Slide

  35. Size Limit (4 Mb)

    View Slide

  36. Size Limit (4 Mb) (10 Mb)

    View Slide

  37. View Slide

  38. View Slide

  39. The Monolith

    View Slide

  40. Location Input

    View Slide

  41. View Slide

  42. Dependency
    Graph

    View Slide

  43. @Component

    View Slide

  44. View Slide

  45. View Slide

  46. Flat Hierarchy

    View Slide

  47. View Slide

  48. View Slide

  49. Dynamic Feature

    View Slide

  50. View Slide

  51. Optimisations
    • Code minification (minifyEnabled)
    • Resource shrinking (shrinkResources)
    • Optimised SVG assets (bit.ly/2SeZePQ)
    • Configuration splits (splits { })
    • Third party SDKs
    !

    View Slide

  52. View Slide

  53. Proguard / R8

    View Slide

  54. Third Party SDKs

    View Slide

  55. Data Binding
    !
    Error: Currently, data binding does not work for non-base feature modules.
    Please, move data binding code to the base feature module.
    See https://issuetracker.google.com/63814741 for details

    View Slide

  56. Data Binding
    !
    android.enableExperimentalFeatureDatabinding=true

    View Slide

  57. Navigation
    Intent(context, CalculatorActivity::class.java)

    View Slide

  58. Navigation
    Intent(context, CalculatorActivity::class.java)

    View Slide

  59. App Links

    View Slide






  60. android:path="/baufinanzierung/finanzierungsrechner/"
    android:scheme="https"/>


    View Slide






  61. android:path="/baufinanzierung/finanzierungsrechner/"
    android:scheme="https"/>


    View Slide

  62. Intent Extras
    val intent = Intent(context, CalculatorActivity::class.java)
    intent.putExtra("location", "Berlin")

    View Slide


  63. View Slide

  64. Query Params
    intent.data?.getQueryParameter("location")

    View Slide

  65. ?

    View Slide

  66. Query Params
    val geocode = intent.data?.getQueryParameter("location")
    val label = intent.data?.getQueryParameter("label")
    val region = if (geocode != null && label != null) Region(geocode, label)
    else null

    View Slide

  67. Query Params
    data class Region(val geocode: String, val label: String) {
    companion object {
    operator fun invoke(
    geocode: String?,
    label: String?
    ) : Region(
    geocode ?: "1276001010",
    label ?: "Berlin - Mitte (Mitte)"
    )
    }
    }

    View Slide

  68. Query Params
    val region = Region(
    intent.data?.getQueryParameter("location"),
    intent.data?.getQueryParameter("label")
    )

    View Slide

  69. Verify Site Associations

    View Slide

  70. keytool -list -v -keystore release.keystore

    View Slide

  71. [{
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
    "namespace": "android_app",
    "package_name": "de.is24.android",
    "sha256_cert_fingerprints": ["..."]
    }
    }]

    View Slide

  72. View Slide

  73. Emulator
    Support

    View Slide

  74. Topeka
    github.com/googlesamples/android-topeka

    View Slide

  75. Plaid
    github.com/nickbutcher/plaid

    View Slide

  76. Next Steps

    View Slide

  77. Cheers!
    !
    ashdavies.io - @askashdavies

    View Slide