Instant Apps: Getting Started

In this tutorial, you’ll learn how to integrate Google Play Instant with your Android project using Instant Development SDK. By Ivan Kušt.

3.7 (3) · 1 Review

Download materials
Save for later

Imagine how great it would be if you could try out apps without even installing them. Well, you can! Google Play Instant enables you to do just that, and this tutorial will show you how to enable this feature for your own apps.

In this tutorial you’ll learn:

  • How to use Instant Development SDK to instant enable your apps.
  • What App Bundles are and how to use them to create instant apps.
  • What App Links are and how to use them in combination with instant apps.
Note: This tutorial assumes you know the basics of Android development with Kotlin. If you are new to Kotlin, check out our Kotlin introduction tutorial. If you are completely new to Android development, read through our Beginning Android Development tutorials to familiarize yourself with the basics.

Getting Started

Google Play Instant enables your apps to launch on devices running Android 5.0 (API level 21) or higher without having to install them first. Apps that run this way are called instant apps or instant games. The experience of running an instant app is referred to as instant experience.

Note: To use Google Play Instant, you’ll need to install Android Studio 3.2 or higher. If you don’t have it, please download it before continuing.

In this tutorial, you’ll practice using instant apps by working with a From Dusk Till Dawn app, which gives you information about important times of the day for any city.

To get started, download the From Dusk Till Dawn project using the Download Materials button at the top or bottom of this tutorial. Open the project in Android Studio 3.2 or later by selecting Open an existing Android Studio project on the Android Studio welcome screen:

In order to build an app that supports Google Play Instant, you need to install the Instant App SDK. Go to Tools ▸ SDK Manager, click on the SDK Tools tab and then install Google Play Instant Development SDK by checking the box and pressing Apply:

Once you have installed the SDK, build and run the project.

After installing the app, grant it permission to access your location:

You’ll see the main screen of the app, which shows the sunrise and sunset times for your location in UTC.

The app consists of two screens:

  • The main screen, which shows information for your current location.
  • The location details screen, which lets you search for information for a different location.

You can search for a location by typing in the city’s name and pressing the magnifier icon on your keyboard.

How Instant Apps Work

An instant app is a special version of your app that runs without the user needing to install it first. The idea is that you have a lighter flavor of your app that enables users to give it a try before they commit to installing it.

You can set up deep link URLs that launch specific activities in your instant app. A typical use for this would be to put different banner links on your site that launch the most relevant activity of your app, all without any installation!

There are some limitations, though. Google Play Instant recognizes two levels of instant experience, with a different app size limitation for each:

  • Basic instant experience: An instant app that launches from a Try Now button or a website banner must have an app size under 10MB.
  • Enhanced instant experience: An instant experience that launches from any surface that can launch a URL, such as messaging apps, email apps or ads, must have an app size under 4MB.

This means that you’ll want to provide a trimmed-down version of your app that showcases what the app can do.

Note: Users have to opt in to instant apps before using them. Here are the steps to opt into instant apps.

There are currently two approaches that you can use to create instant apps or to enable your current app to be instant-ready:

  • Feature plugins.
  • App Bundles.
Note: Google recommends using App Bundles. If you want to learn more about using feature plugins, you can check the official feature plugin documentation.

In this tutorial, you’ll learn how to use App Bundles to add an instant app experience to an existing app.

App Bundles

Android App Bundle, which uses the .aab extension, is the new delivery format that replaces .apk archives for publishing Android apps to the Google Play Store.

How does it work? App Bundle contains all of the compiled code and resources. When users request to download your application from Google Play Store, the store uses a new serving model called Dynamic delivery.

Dynamic delivery generates and serves an .apks archive optimized for the user’s device. That way, the download includes only the code and resources it really needs, which results in a smaller application size and a smaller download. An added benefit is that you no longer have to manage multiple .apk files to support different devices.

Note: For more information on App Bundles, check out our tutorial on Getting Started With App Bundles.

Your First Instant App

Now that you know how Instant apps and App Bundles work, you’re ready to make your first instant-enabled app!

The first thing you’ll need to do is add a new flavor that contains an instant version of the app.

Open the build.gradle file in the app folder and add a new flavor dimension to determine whether you are using an instant or an installed version of the app:

flavorDimensions "experience"
productFlavors {
  instant {
    versionCode 1
  installed {
    versionCode 2

This defines two new flavors in the experience flavor dimension:

  • The instant flavor, which contains the instant version of the app.
  • The installed flavor, which contains the installed version of the app.

One very important thing to note is that the code size of the instant flavor version must be smaller than the code size of the installed flavor version. This allows users to upgrade from the instant app to the installed version of the app.

Make sure everything still works by building and running the app.