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

Introduction to Android Instant Apps

Introduction to Android Instant Apps

Android Instant Apps are the new kid in the large town of Android-city. The promise behind it is quite simple and groundbreaking at the same time: running native Android apps instantly on your device, without installation.

In this session we will first introduce this evolution in app sharing and discovery mostly from a user perspective. Secondly, we will discover how, as a developer, you can build an Android Instant Apps and deliver this new experience frictionless to all of your users.

Cyril Mottier

October 20, 2017
Tweet

More Decks by Cyril Mottier

Other Decks in Programming

Transcript

  1. >

  2. > >

  3. >

  4. > >

  5. <intent-filter android:autoVerify="true"> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <action android:name="android.intent.action.VIEW"

    /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:host="${host}" android:path="/licenses" /> </intent-filter> android:autoVerify="true"
  6. <intent-filter android:autoVerify="true"> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <action android:name="android.intent.action.VIEW"

    /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:host="${host}" android:path="/licenses" /> </intent-filter> android:autoVerify="true"
  7. <intent-filter android:autoVerify="true"> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <action android:name="android.intent.action.VIEW"

    /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:host="${host}" android:path="/licenses" /> </intent-filter> android:autoVerify="true"
  8. https://<host>/.well-known/assetlinks.json [ { "relation": [ "delegate_permission/common.handle_all_urls" ], "target": { "namespace":

    "android_app", "package_name": "com.gdgnantes.devfest.android", "sha256_cert_fingerprints": [ "1A:24:9C:B5:69:5F:B5:21:CD:80:45:7A:06:20:C5:78:DB: 07:A8:CA:A0:8F:E9:47:B9:F6:A5:60:6B:78:DB:32" ] } } ]
  9. https://<host>/.well-known/assetlinks.json [ { "relation": [ "delegate_permission/common.handle_all_urls" ], "target": { "namespace":

    "android_app", "package_name": "com.gdgnantes.devfest.android", "sha256_cert_fingerprints": [ "1A:24:9C:B5:69:5F:B5:21:CD:80:45:7A:06:20:C5:78:DB: 07:A8:CA:A0:8F:E9:47:B9:F6:A5:60:6B:78:DB:32" ] } } ] "relation": [ "delegate_permission/common.handle_all_urls" ]
  10. https://<host>/.well-known/assetlinks.json [ { "relation": [ "delegate_permission/common.handle_all_urls" ], "target": { "namespace":

    "android_app", "package_name": "com.gdgnantes.devfest.android", "sha256_cert_fingerprints": [ "1A:24:9C:B5:69:5F:B5:21:CD:80:45:7A:06:20:C5:78:DB: 07:A8:CA:A0:8F:E9:47:B9:F6:A5:60:6B:78:DB:32" ] } } ] "namespace": "android_app" "target": { }
  11. https://<host>/.well-known/assetlinks.json [ { "relation": [ "delegate_permission/common.handle_all_urls" ], "target": { "namespace":

    "android_app", "package_name": "com.gdgnantes.devfest.android", "sha256_cert_fingerprints": [ "1A:24:9C:B5:69:5F:B5:21:CD:80:45:7A:06:20:C5:78:DB: 07:A8:CA:A0:8F:E9:47:B9:F6:A5:60:6B:78:DB:32" ] } } ] "package_name": "com.gdgnantes.devfest.android" "target": { }
  12. https://<host>/.well-known/assetlinks.json [ { "relation": [ "delegate_permission/common.handle_all_urls" ], "target": { "namespace":

    "android_app", "package_name": "com.gdgnantes.devfest.android", "sha256_cert_fingerprints": [ "1A:24:9C:B5:69:5F:B5:21:CD:80:45:7A:06:20:C5:78:DB: 07:A8:CA:A0:8F:E9:47:B9:F6:A5:60:6B:78:DB:32" ] } } ] "sha256_cert_fingerprints": [ "1A:24:9C:B5:69:5F:B5:21:CD:80:45:7A:06:20:C5:78:DB: 07:A8:CA:A0:8F:E9:47:B9:F6:A5:60:6B:78:DB:32" ] "target": { }
  13. https://<host>/.well-known/assetlinks.json [ { "relation": [ "delegate_permission/common.handle_all_urls" ], "target": { "namespace":

    "android_app", "package_name": "com.gdgnantes.devfest.android", "sha256_cert_fingerprints": [ "1A:24:9C:B5:69:5F:B5:21:CD:80:45:7A:06:20:C5:78:DB: 07:A8:CA:A0:8F:E9:47:B9:F6:A5:60:6B:78:DB:32" ] } } ]
  14. Application icon Custom font management Common styles, dimens, colors, …

    Base Activity/Fragment implementation Utilities etc. What about the base APK? contains code/resources used in all modules
  15. apply plugin: 'com.android.feature' android { //... baseFeature true } dependencies

    { application project(':app') feature project(':features:about') feature project(':features:licenses') } ./features/base/build.gradle
  16. apply plugin: 'com.android.feature' android { //... baseFeature true } dependencies

    { application project(':app') feature project(':features:about') feature project(':features:licenses') } ./features/base/build.gradle apply plugin: 'com.android.feature'
  17. apply plugin: 'com.android.feature' android { //... baseFeature true } dependencies

    { application project(':app') feature project(':features:about') feature project(':features:licenses') } ./features/base/build.gradle baseFeature true
  18. apply plugin: 'com.android.feature' android { //... baseFeature true } dependencies

    { application project(':app') feature project(':features:about') feature project(':features:licenses') } ./features/base/build.gradle application project(':app') feature project(':features:about') feature project(':features:licenses')
  19. apply plugin: 'com.android.feature' android { //... baseFeature true } dependencies

    { application project(':app') feature project(':features:about') feature project(':features:licenses') } ./features/base/build.gradle
  20. apply plugin: ‘com.android.instantapp' //... dependencies { implementation project(':features:base') implementation project(':features:about')

    implementation project(':features:licenses') } ./instant/build.gradle apply plugin: ‘com.android.instantapp'
  21. Play Store dev tracks 10MB During development ∞ Maximum download

    bundle size (i.e. that weird “ ” constant)
  22. 4MB Play Store production Play Store dev tracks 10MB During

    development ∞ Maximum download bundle size (i.e. that weird “ ” constant)
  23. Slim down your APK size Dependencies reduction Code minification Vector

    graphics Resource shrinking Downloadable fonts Resources de-duplication Remote fetching Images optimisation WebP format Granular dependencies Density bucket removal Native code architecture removal Wear 2.0 APK distribution Sparse translation elimination Version collapsing
  24. android { //... generatePureSplits true splits { abi { enable

    true } density { enable true } language { enable true include "en", "fr" } } } ./base.build.gradle
  25. Cookie API // Instant app with(packageManager) { if (cookie.size <=

    instantAppCookieMaxBytes) { updateInstantAppCookie(cookie) } }
  26. // Installable app val cookie = packageManager.instantAppCookie // ... (i.e.

    restore user data) packageManager.clearInstantAppCookie() Cookie API
  27. Instant App Data val client = InstantApps.getInstantAppsClient(this) val fileTask =

    client.instantAppData fileTask .addOnCompleteListener { readData(it.result) } .addOnFailureListener { handleException(it) }