You create an Google Play Instant experience by including it as part of an Android App Bundle. Such a bundle is known as an instant-enabled app bundle. This document shows you how to set up your development environment for instant-enabled app bundles, as well as how to configure, build, test, and publish an instant-enabled app bundle.
Set up development environment
To prepare your development environment for creating instant-enabled app bundles, obtain the following tools if you haven't done so already:
- Android Studio 3.3 or higher.
- Google Play Instant Development SDK: Download the latest version of this SDK from the SDK Tools tab within the Android SDK Manager.
- Target device: Use either a physical or virtual device to test the instant app experience.
Configure your project for instant experiences
To be compatible with Google Play Instant, you must configure several aspects of your instant-enabled app bundle carefully. The following sections describe these considerations.
Instant-enabled app modules
You can declare that your app bundle supports instant experiences using one of the following methods:
- If you're creating a new project in Android Studio, during the Configure your project step, select the This project will support instant apps checkbox.
If you have an existing app bundle that contains only a base module, you can instant-enable the app bundle by adding the following declaration to the module's manifest:
<manifest ... xmlns:dist="http://schemas.android.com/apk/distribution"> <dist:module dist:instant="true" /> ... </manifest>
If you have an existing app bundle that contains multiple modules, you can Create an instant-enabled dynamic feature module. This process also instant-enables your app's base module, giving you the option to support multiple instant entry points within your app.
Instant-enabled app bundles can only use permissions from the following list:
BILLING– Deprecated as of Play Billing Library 1.0.
INSTANT_APP_FOREGROUND_SERVICE– Only in Android 8.0 (API level 26) and higher.
READ_PHONE_NUMBERS– Only in Android 8.0 (API level 26) and higher.
Google Play Instant runs instant-enabled app bundles in a special kind of SELinux sandbox for added security. To be compatible with this environment, you need to create the following configuration within your instant-enabled app bundle:
- In your Network Security Config, set
- Don't share the value of
myUid(), which is your app process's kernel-assigned UID.
Build the app bundle
Using Android Studio, you can build your app bundle by selecting Build > Build Bundle(s) / APK(s) > Build Bundle(s). For more information about building your project, see Build your project.
Test the instant experience
Before publishing your instant-enabled app bundle, you can test the instant experience—both on a local machine and by publishing to the internal test track—to verify functionality within your app's instant experiences.
Test on a local machine
To test your app's instant experience on a local machine, complete the following steps:
If you have an installed version of your app on your test device, uninstall it.
In Android Studio, from the installation options that appear on the General tab of the Run/Debug Configurations dialog, enable the Deploy as instant app checkbox.
Select Run > Run in the menu bar, or click Run in the toolbar, then choose the device where you'd like to test your app's instant experiences. Your app's instant experience loads on the test device that you've chosen.
Publish to the internal test track
To test your app's instant experience from the Play Store or a banner on your website, publish the app to the internal test track on the Play Console. To do so, complete the following steps:
Upload your app bundle by following the steps in the Upload your app bundle to the Play Console guide.
Prepare the uploaded bundle for a release to the internal test track. For more information, see the support article on how to Prepare & roll out releases.
Sign into an internal tester account on a device, then launch your instant experience from one of the following surfaces:
- The Try Now button from your app's Play Store listing.
- A link from a banner on your app's website.
Publish the app bundle to the production track
To publish your instant-enabled app bundle, complete the following steps:
- If you haven't already, sign your app bundle with a release key and upload the app bundle to the Play Console.
- In the Play Console, open Release management > Android Instant Apps, then navigate to the instant app production track.
- Select Update from Library, then select the instant-enabled app bundle that you've uploaded.
To learn more about creating instant experiences and Android App Bundles, see the following resources:
- Video: Bundling an App in an Instant
- Learn how to add an instant experience to an Android App Bundle in this session from Android Dev Summit '18.
- Video: Publish smaller apps with the Android App Bundle
- Learn how app bundles help you develop your app more quickly and create smaller APKs for your users.
- Codelab: Your First Android App Bundle
- A step-by-step guide for creating an Android App Bundle and adding features to it.
- The Android App Bundle Format
- Learn more about how the
bundletoolcommand-line program organizes an app bundle from your app's code and resources.