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

⚡️ Android Instant Apps ⚡️

⚡️ Android Instant Apps ⚡️

Instant apps are Android apps that run without installation. It’s an interesting new concept that’s good for both users and app creators. Let me tell you how it all works, what it looks like for users and how to build an instant app.

Marcin Koziński

August 22, 2017
Tweet

More Decks by Marcin Koziński

Other Decks in Programming

Transcript

  1. – me, right now “What if you didn’t have to

    install Android apps to use them?”
  2. https://developer.android.com/topic/instant-apps/index.html “Native Android apps that run instantly,
 without the installation”

    “An upgrade to your existing Android app, not a new, separate app. It's the same Android APIs, the same project, and the same source code.”
  3. Requirements • Support deep linking and App Links • Slim

    down your app, hard limit 4MB per download • Implement runtime permissions • If you need log in/sign in - use Smart Lock • If you need payments - use Google Payment API
  4. Restrictions • No running in the background • No push

    notifications • No access to external storage • You can’t see a full list of apps installed on the device • Only available device identifier: Advertising ID • Can’t change device settings such as change the user's wallpaper • You’ll receive only some implicit broadcasts
  5. Restrictions • Network traffic from inside the instant app must

    be encrypted using a TLS protocol like HTTPS
  6. Deep links <activity android:name=".HelloActivity" android:label="@string/title_activity_hello"> <intent-filter> <action android:name="android.intent.action.VIEW" "/> <category

    android:name="android.intent.category.BROWSABLE" "/> <category android:name="android.intent.category.DEFAULT" "/> <data android:scheme="https" "/> <data android:scheme="http" "/> <data android:host="hello.instantappsample.com" "/> <data android:pathPrefix="/hello" "/> "</intent-filter> "</activity> """<!-- https:"//hello.instantappsample.com/hello/world ""-->
  7. Deep links "// Later in activity onCreate final Uri uri

    = getIntent().getData(); if (uri "!= null) { uri.getPathSegments(); "// List ["hello", "world"] }
  8. App Links <activity android:name=".HelloActivity" android:label="@string/title_activity_hello"> <intent-filter> <action android:name="android.intent.action.VIEW" "/> <category

    android:name="android.intent.category.BROWSABLE" "/> <category android:name="android.intent.category.DEFAULT" "/> <data android:scheme="https" "/> <data android:scheme="http" "/> <data android:host="hello.instantappsample.com" "/> <data android:pathPrefix="/hello" "/> "</intent-filter> "</activity>
  9. App Links <activity android:name=".HelloActivity" android:label="@string/title_activity_hello"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" "/>

    <category android:name="android.intent.category.BROWSABLE" "/> <category android:name="android.intent.category.DEFAULT" "/> <data android:scheme="https" "/> <data android:scheme="http" "/> <data android:host="hello.instantappsample.com" "/> <data android:pathPrefix="/hello" "/> "</intent-filter> "</activity>
  10. App Links • Upload a special JSON to a “well-known”

    location on your servers.
 https://<your.server>/.well-known/assetlinks.json • https://d.android.com/training/app-links/index.html • http://zdominguez.com/2017/01/20/testing-autoverify.html • App links assistant in Android Studio • MCE 2017: Cyril Mottier, Seamless Linking to Your App
  11. Default URL <activity android:name=".HelloActivity" android:label="@string/title_activity_hello"> <intent-filter> <action android:name="android.intent.action.MAIN" "/> <category

    android:name="android.intent.category.LAUNCHER" "/> "</intent-filter> <intent-filter> …q "</intent-filter> <meta-data android:name="default-url" android:value="https:"//hello.instantappsample.com/hello" "/> "</activity>
  12. Let me explain you 4MB limit • You: <4MB? NO

    WAI • Me: YAS WAI $ • APK Analyzer, Proguard, shrink resources/unused resources, .webp, … • Android Instant Apps: Best practices for managing download size • Wojtek Kaliciński: #SmallerAPK, session at Google I/O '17
  13. Single-feature instant app .java :app .java .xml .png apply plugin:

    'com.android.application' .java :base apply plugin: 'com.android.library'
  14. Single-feature instant app .java :app .java .xml .png apply plugin:

    'com.android.application' .java :base "//apply plugin: 'com.android.library' apply plugin: 'com.android.feature'
  15. Single-feature instant app .java :app .java .xml .png apply plugin:

    'com.android.application' .java :base "//apply plugin: 'com.android.library' apply plugin: 'com.android.feature' :instantapp apply plugin: 'com.android.instantapp'
  16. Single-feature instant app :app apply plugin: 'com.android.application' :base baseFeature true

    dependencies { "//… application project(‘:app') } :instantapp apply plugin: 'com.android.instantapp'
  17. Tools • Android Studio 3.0, Android Gradle Plugin 3.0 (currently

    beta). • Instant Apps SDK (downloadable from the SDK Manager in AS). •aimplementation 'com.google.android.instantapps:instantapps:1.0.0' • Mostly all existing libraries, subject to “requirements & restrictions” • Mostly normal workflow: run from AS, attach debugger, etc.
 (Note: need to sign in with a Google account on device/emulator.)
  18. Learn more… • https://g.co/instantapps • Fragmented Podcast #090: Make your

    apps instant with Zarah Dominguez • 3 Google I/O '17 sessions (linked here, here and here) • Android Instant Apps, step-by-step: how Vimeo went about it • From Westinghouse to Android Instant apps, a BuzzFeed Journey • Ask me @marcinkozinski or Mobile Warsaw Slack