Search code examples
androidgoogle-playgoogle-play-consoleandroid-asset-deliveryandroid-assetpacks

How to generate an APK with all assets from asset packs included?


I have android application with asset packs downloading at install time. Now I need an APK(galaxy build) with all the assets from asset packs included in it.

I have tried including this in app's build.gradle file

if (project.hasProperty("includeAssets")) { assetPacks = [":play_asset_test"] }

and used ./gradlew assembleGalaxyArm64Release -PincludeAssets to generate apk. But this didn't work.

How to generate an APK with all assets from asset packs included?


Solution

  • I used used gradle properties and added it in the command and based on the property, include the asset pack location.

    Gradle command:

    ./gradlew --project-prop includeAssetPackFiles assemblePlayArm64Release
    

    In build.gradle set asset folders paths

    if (project.hasProperty("includeAssetPackFiles")) {
         assets.srcDirs = ['../play_asset_test/src/main/assets', 'assets', '../play_asset_test_ff/src/main/assets']
    } else {
         assets.srcDirs = ['assets']
    }
    

    This worked for me. Please share if there are any other approaches.