lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

Create an instant app

Codelab: Build Your First Instant App

Add support for Google Play Instant in an existing app.

Codelab: Build a Multi-Feature Instant App

Modularize a multi-feature app.

This guide teaches you how to set up your development environment for working with instant apps. You then learn how to create, run, and debug an Android Studio project containing an instant app. Finally, the guide provides resources on publishing an instant app.

Prepare your development environment

In Android Studio, open the Android SDK Manager. On the SDK Platforms tab, make sure that Android 6.0 (Marshmallow) or later is installed.

Then, open the SDK Tools tab, and install the following packages:

  • Android SDK Build-Tools 26.x or higher
  • Android SDK Platform Tools 25.x or higher
  • Android SDK Tools (latest)
  • Instant Apps Development SDK (latest)
  • Support Repository (latest)
    • All dependencies of Support Repository (latest version for each)

Create your instant app project

To create an instant app, complete the following steps:

  1. Launch Android Studio and create a new project:
    • If you haven't opened a project yet, in the Welcome to Android Studio window, click Start a new Android Studio project.
    • If you already have a project open, select File > New Project.
  2. In the Create Android Project window, do the following:
    1. In the Application name box, enter "My First Instant App".
    2. In the Company domain box, enter "example.com".
    3. Leave the Package name as "com.example.myfirstinstantapp".
    4. Click Next.
  3. In the Target Android Devices window, do the following:
    1. Ensure that Phone and Tablet is selected.
    2. Under the Minimum SDK list, check Include Android Instant App support. Click Next.
  4. In the Customize Instant App Support window, leave the default settings. Click Next.
  5. In the Add an Activity to Mobile window, select Empty Activity. Click Next.
  6. In the Configure Activity window, do the following:
    • In the Instant App URL Host box, enter "myfirstinstantapp.example.com" (without the quotation marks).
    • In the Instant App URL route box, enter "/hello" (without the quotation marks).
    • Keep the default values of the other settings.
    • Click Finish.

Android Studio builds and loads your new project's files.

Run your instant app

You can develop instant apps on most devices running Android 5.1 (API level 21) or higher. If you don't have a test device, read the following section to learn how you can set up an emulator for running instant apps.

To run the project in Android Studio, do the following:

  1. Click the instantapp module in the Project window and then select Run > Run 'instantapp'.
  2. In the Select Deployment Target window, select your test device or emulator where you'd like to run the app.

Android Studio builds your app, then installs it on your test device or emulator.

Set up an emulator that supports instant apps

To set up your emulator for running instant apps, complete the following steps:

  1. Create an Android Virtual Device that runs Android 8.1 (API level 27) or later, uses the x86 architecture, and includes Google APIs.

  2. Start your emulator and log into a test Google account.

  3. In the system's Settings menu, go to Google > Instant Apps and opt into Android Instant Apps.

Debug your instant app

When developing instant apps, you might encounter some errors. This section includes several of the most common situations that you might need to handle.

Load URL in the browser instead of instant app

A common issue when you run an instant app is that the browser tries to load the URL instead of running the instant app. This problem occurs for a variety of different reasons.

To fix this issue, complete these steps:

  1. Check adb logcat to see if there are any details on why the browser opened instead of your instant app.

    The following type of Logcat message is particularly common:

    E/AndroidRuntime: FATAL EXCEPTION: IntentService[IapkLoadService]
    Process: com.google.android.instantapps.devman, PID: 5951
    android.database.sqlite.SQLiteConstraintException: UNIQUE constraint
    failed: Domains.domain (code 1555)
    

    In this situation, clear your DevMan database by running the following command:

    $ adb shell pm clear com.google.android.instantapps.devman
    
  2. Ensure that your URLs are mapped in the AndroidManifest.xml file within your base feature module. In particular, check that each URL being used in your <intent-filter> uses the correct host, scheme, and path:

    <intent-filter android:order="2">
        <data
            android:host="example.com"
            android:scheme="https"
            android:pathPrefix="/hello"/>
    </intent-filter>
    

Deploy your instant app for publishing

To prepare your instant app for publishing, complete the following steps:

  1. In Android Studio, select Build > Generate Signed APK...
  2. In the Generate Signed APK window, choose the instantapp module. Click Next.
  3. Complete the steps described in the Distribute your instant app article.
  4. Navigate to the Google Play Console to complete the workflow, as described in the Prepare & rollout releases article. Make sure you upload your instant app APK.

To learn more about how to prepare and roll out your app in the Google Play Console, see Sign your APK.