Share
Embed
⚡️ 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
Transcript
30 slides
-
– me, right now “What if you didn’t have to
install Android apps to use them?” -
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.” -
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 -
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 -
Restrictions • Network traffic from inside the instant app must
be encrypted using a TLS protocol like HTTPS -
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 ""--> -
Deep links "// Later in activity onCreate final Uri uri
= getIntent().getData(); if (uri "!= null) { uri.getPathSegments(); "// List ["hello", "world"] } -
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> -
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> -
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 -
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> -
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 -
.zip .zip .apk .apk .apk .apk .apk features: base: single
feature multi-feature -
apply plugin: 'com.android.application' apply plugin: 'com.android.library' apply plugin: 'com.android.instantapp' apply
plugin: 'com.android.feature' a -
Single-feature instant app .java :app .java .xml .png apply plugin:
'com.android.application' .java -
Single-feature instant app .java :app .java .xml .png apply plugin:
'com.android.application' .java :base apply plugin: 'com.android.library' -
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' -
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' -
Single-feature instant app :app apply plugin: 'com.android.application' :base baseFeature true
dependencies { "//… application project(‘:app') } :instantapp apply plugin: 'com.android.instantapp' -
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.) -
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