Google is committed to advancing racial equity for Black communities. See how.

Build for native or Java

Use the following steps to build Play Asset Delivery into your project’s Android App Bundle. You don't need to use Android Studio to perform these steps.

  1. Import the Play Core Library into your project.

  2. Update the version of the Android Gradle plugin in your project’s build.gradle file to 4.0.0 or later.

  3. In the top-level directory of your project, create a directory for the asset pack. This directory name is used as the asset pack name. Asset pack names must start with a letter and can only contain letters, numbers, and underscores.

  4. In the asset pack directory, create a build.gradle file and add the following code. Make sure to specify the name of the asset pack and only one delivery type:

    // In the asset pack’s build.gradle file:
    apply plugin: 'com.android.asset-pack'
    
    assetPack {
        packName = "asset-pack-name" // Directory name for the asset pack
        dynamicDelivery {
            deliveryType = "[ install-time | fast-follow | on-demand ]"
        }
    }
    
  5. In the project’s app build.gradle file, add the name of every asset pack in your project as shown below:

    // In the app build.gradle file:
    android {
        ...
        assetPacks = [":asset-pack-name", ":asset-pack2-name"]
    }
    
  6. In the project’s settings.gradle file, include all asset packs in your project as shown below:

    // In the settings.gradle file:
    include ':app'
    include ':asset-pack-name'
    include ':asset-pack2-name'
    
  7. In the asset pack directory, create the following subdirectory: src/main/assets.

  8. Place assets in the src/main/assets directory. You can create subdirectories in here as well. The directory structure for your app should now look like the following:

    • build.gradle
    • settings.gradle
    • app/
    • asset-pack-name/build.gradle
    • asset-pack-name/src/main/assets/your-asset-directories
  9. Build the Android App Bundle with Gradle. In the generated app bundle, the root-level directory now includes the following:

    • asset-pack-name/manifest/AndroidManifest.xml: Configures the asset pack’s identifier and delivery mode
    • asset-pack-name/assets/your-asset-directories: Directory that contains all assets delivered as part of the asset pack

    Gradle generates the manifest for each asset pack and outputs the assets/ directory for you.

Next step

Integrate Play Asset Delivery into your game or app code using one of the following: