Skip to content

Most visited

Recently visited

navigation

Prepare your app

The best instant app experiences are focused on helping the user accomplish a task quickly (e.g. watching a video or making a purchase). You can start getting your app ready for Android Instant Apps by working through this list of steps. Many of these are considered best practices for Android apps generally.

Remove any unneeded bulk from your app

Get rid of any unknown or unused permissions, unused components, unneeded third-party dependencies, and libraries. Removing these items can dramatically reduce the size of your app and improve performance significantly.

For more information about how to identify permissions specified in your app manifest, see <uses-permission> and App Manifest.

For more information about how to identify and remove unneeded components in your app, see Reduce APK Size.

Android Instant Apps uses URLs for all navigation. When a user taps a link to your instant app, they go to a specific activity within your app. If the link fails or the user taps the link on an unsupported device, the browser opens and shows your website. Also, an activity cannot launch another activity directly within an instant app; rather, it must request the URL address that corresponds to that activity.

Both your instant and installable versions of your app must implement the Android App Links feature introduced in Android 6.0. App Links provide the primary mechanism for connecting URLs to discrete activities within your app. It is recommended that your app supports both www and non-www domains. To get started with App Links, see the information on Handling Android App Links.

In addition, an instant app cannot launch an activity in another feature directly; instead, it must request the URL address that corresponds to the other other feature's entry-point activity. For more information, see Implement app links.

Refactor your app, if necessary

Android Instant Apps need to be structured into URL-addressable modules that are under 4MB in size. For apps that are larger than 4MB, developers must refactor the app into smaller modules that can be downloaded and run independently in response to URL navigation. Developers are free to choose what to include in each module, but it is recommended to isolate distinct user flows into different modules. This gives a fast and responsive experience within a flow and additional modules are downloaded only when the user switches flows. For example, when building a retail experience, you can separate your app into four modules: browse, search, item detail, and checkout to allow the user to download modules as needed throughout the purchase flow.

Implement runtime permissions from Android 6.0

Android Instant Apps requires the use of runtime permissions introduced in Android 6.0 (API level 23). The Android Instant Apps framework ensures that these features work correctly on earlier versions of Android as well. As such, please make sure your app is targeting Android 6.0+ and using runtime permissions.

For more information on how to update your app to use Android 6.0 permissions and how to request permissions at runtime, see Requesting Permissions at Run Time.

Implement Smart Lock for Passwords if your app authenticates users

For instant apps that include login, developers must integrate Smart Lock for Passwords. This allows users to quickly and securely sign in by using the credentials they have saved, as well as for users to remain signed in across app visits.

For more information about how to implement Smart Lock in your app, see Smart Lock for Passwords on Android.

Accept payments with the Google Payment API

For accepting payments, Android Instant Apps is compatible with the Google Payment API for physical goods and services.

Implementing Google Payment API

Google Payment API uses a similar API surface as Android Pay. The PAYMENT_GATEWAY tokenization type is required for Android Instant Apps and is currently supported for developers processing payments with Braintree, Stripe, or Vantiv. With the Google Payment API, your app can request any credit or debit card from the user's Google account, as well as Android Pay payment credentials.

Even though Google Payment API is very similar to Android Pay, there are some differences to keep in mind:

@Override
public void onClick(View view) {
    MaskedWalletRequest request = createMaskedWalletRequest(cartTotal);
    Wallet.Payments.loadMaskedWallet(mGoogleApiClient, request,
        REQUEST_CODE_MASKED_WALLET);
}

private MaskedWalletRequest createMaskedWalletRequest(String cartTotal) {

    // This creates parameters needed to work with the Stripe payment
    // processors. It is always best to check with your payment processor
    // (including stripe) to get the configuration that is required.
    //
    // Also note that PAYMENT_GATEWAY is required for the payment API and
    // the other option of NETWORK_TOKEN is not supported.
    PaymentMethodTokenizationParameters params =
            PaymentMethodTokenizationParameters.newBuilder()
                .setPaymentMethodTokenizationType(
                     PaymentMethodTokenizationType.PAYMENT_GATEWAY)
                .addParameter(“gateway”, “stripe”)
                .addParameter(“stripe:publishableKey”, KEY)
                .addParameter(“stripe:version”, version)
                .build();

    // Convert our cart to a list of LineItem that is used to build
    // the MaskedWalletRequest. Note: Implementation not shown.
    List<LineItem> lineItems = buildLineItems();

    MaskedWalletRequest request = MaskedWalletRequest.newBuilder()
        .setMerchantName(YOUR_NAME_HERE)
        .setPhoneNumberRequired(true)
        .setShippingAddressRequired(true)
        .setCurrencyCode(“USD”)
        .setEstimatedTotalPrice(cartTotal)
        .setCart(Cart.newBuilder()
                     .setCurrencyCode(“USD”)
                     .setTotalPrice(cartTotal)
                     .setLineItems(lineItems)
                     .build())
        .setPaymentMethodTokenizationParameters(params)
        .build();
    return request;
}

For more information about how to implement Android Pay, see the Android Pay developers site.

Define an entry point for your app

To allow Google Play and Android launcher to discover your app, you must provide at least one activity as the entry point for your app. In the manifest for your app, the entry point activity must have an <intent-filter> element that includes the CATEGORY_LAUNCHER and ACTION_MAIN intents.

Your app must also define a default URL for your app. Within the same Android manifest as your entry-point activity, you define the default URL for your app by adding a <meta-data> element with a value attribute that provides a valid HTTPS URL that the activity can handle. Further, this default url must also be part of the CATEGORY_LAUNCHER activity's intent filter in the installed app.

The following code snippet shows an Android manifest that defines an entry-point activity and default URL for an instant app.

<activity
  android:name=".MainActivity">
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter android:autoVerify="true">
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="http" />
      <data android:scheme="https" />
      <data android:host="example.com" />
    </intent-filter>
    <meta-data
      android:name="default-url"
      android:value="https://www.example.com/index.html" />
</activity>

Identify tested compatible libraries

Android Instant Apps are compatible with a large selection of Google libraries, including those in the following list. Other libraries not included in this list have not been tested and verified as compatible with Android Instant Apps.

When debugging an instant app that uses a library other than those included in the previous list, you may see the API_UNAVAILABLE error in your debugging output. The API_UNAVAILABLE error indicates that the library has not been approved for usage in Android Instant Apps.

For additional support, please check the Android Instant Apps posts on StackOverflow.

Identify allowed implicit broadcast intents

An instant app can receive the following broadcast intents:

Prepare for Android O

Starting in Android O Developer Preview 2, the Android O image supports instant app development. In addition to other requirements listed on this page and elsewhere in the Android Instant Apps documentation, you must do the following to prepare your instant app for Android O:

Identify restricted and unsupported features

User expectations may vary for apps that are installed as opposed to apps accessed via URL. Thus, certain functionality available to installed apps is not available to instant apps. Developers using any of the below functionality must refactor their app to move unsupported features to a separate library module to be included only in their installed app.

Address additional app requirements

In addition to other requirments listed on this page and elsewhere in the Android Instant Apps documentation, you must do the following to prepare your instant app:

Restricted features

Caution: An instant app cannot use alternate means to bypass the restrictions described above. Do not attempt to use custom APIs or functionality provided by device manufacturers. Google will remove apps that violate these restrictions.

Unsupported features

Hardware Acceleration

Android Instant Apps support OpenGL ES 2.0 with the exception of context share groups. The following extensions are supported:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.