Google Play Instant allows users to interact with your app without needing to install APK(s) on their device. Instead, they can experience your app through the "Try Now" button on the Google Play Store or a URL that you create. This form of delivering content makes it easier for you to increase engagement with your app.
You can instant-enable a dynamic feature only if you also instant-enable your app’s base module. That’s because, if a user wants to experience one of your app’s instant-enabled dynamic features, their device must also download your app’s base module for common code and resources. Keep in mind, to support Google Play Instant, the download for your base module and dynamic feature must satisfy strict size restrictions. To learn more, read Enable instant experiences by reducing app or game size.
If you create an instant-enabled dynamic feature module using Android Studio 3.3 or higher, as described in this section, the IDE automatically instant-enables both the base and dynamic feature module for you by including the following in each module’s manifest:
<manifest xmlns:dist="http://schemas.android.com/apk/distribution" ... > <dist:module dist:instant="true" /> ...
Keep in mind, when you set
dist:instant="true", you cannot also set
dist:onDemand="true". That is, when downloading and installing your app,
instant-enabled dynamic features are automatically downloaded and installed with
your app’s base APK. However, you can still request instant-enabled modules on
demand within your instant experience
using the Play Core Library.
Configure a new module for instant delivery
To add an instant-enabled dynamic feature module to your app project using Android Studio, proceed as follows:
- If you haven’t already done so, open your app project in the IDE.
- Select File > New > New Module from the menu bar.
- In the Create New Module dialog, select Instant Dynamic Feature Module and click Next.
In the Configure your new module section, complete the following:
- Select the Base application module for your app project from the dropdown menu.
- Specify a Module name. The IDE uses this name to identify the
module as a Gradle subproject in your
Gradle settings file. When you
build your app bundle, Gradle uses the last element of the subproject
name to inject the
<manifest split>attribute in the dynamic feature module’s manifest.
- Specify the module’s package name. By default, Android Studio suggests a package name that combines the root package name of the base module and the module name you specified in the previous step.
- Select the Minimum API level you want the module to support. This value should match that of the base module.
Specify the Module title using up to 50 characters. The platform uses this title to identify the module to users. For this reason, your app’s base module must include the module title as a string resource, which you can translate. When creating the module using Android Studio, the IDE adds the string resource to the base module for you and injects the following entry in the dynamic feature module’s manifest:
<dist:module ... dist:title="@string/title_dynamic_feature"> </dist:module>
Check the box next to Fusing if you want this module to be available to devices running Android 4.4 (API level 20) and lower and included in multi-APKs. Android Studio injects the following in the module’s manifest to reflect your choice.
<dist:module ... <dist:fusing dist:include="true" /> </dist:module>
After Android Studio finishes creating your module, inspect its contents yourself from the Project pane (select View > Tool Windows > Project from the menu bar). The default code, resources, and organization should be similar to those of the standard app module.
After you implement a feature that you want to download on demand, learn how to request it using the Play Core libraru.
Deploy your app
While you're developing your app with support for Dynamic Delivery, you can deploy your app to a connected device like you normally would by selecting Run > Run from the menu bar (or by clicking Run in the toolbar).
If your app project includes one or more dynamic feature modules, you can choose which dynamic features to include when deploying your app by modifying your existing run/debug configuration as follows:
- Select Run > Edit Configurations from the menu bar.
- From the left panel of the Run/Debug Configurations dialog, select your desired Android App configuration.
- Under Dynamic features to deploy in the General tab, check the box next to each dynamic feature module you want to include when deploying your app.
- Click OK.
By default, Android Studio doesn't deploy your instant-enabled modules as an instant experience or use app bundles to deploy your app. Instead, the IDE builds and installs APKs to your device that are optimized for deployment speed, rather than APK size. To configure Android Studio to instead build and deploy APKs and instant experiences from an app bundle, modify your run/debug configuration.
To learn more about using supporting Dynamic Delivery, try the following resource.
- PlayCore API sample, a sample app that demonstrates usage of the PlayCore API to request and download dynamic features.