October 24, 2024
Chicago 12, Melborne City, USA
Android

Android Asset Packs – gradlew wrongly concatenates assets dirs


I have 2 asset packs (long and notlong) I want to dynamically download upon request.

For some reason instead of looking at each asset pack dir sepeately, gradle is combining the long and notlong asset pack dirs as if they are one when I try to build the bundle, with the command:

./gradlew bundleDebug --stacktrace --info

Regular app build works as expected.
The error gradle returns is:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:assetPackDebugPreBundleTask'.
...
Caused by: java.nio.file.NoSuchFileException: 

/full/project/path/long/src/main/assets:/full/project/path/notlong/src/main/assets

both directories obviously exists separately, but gradle for some reason treats them as if it’s one single directory with this long name with column in between.

My project structure is:

<project-root>
├── app
│   ├── src
│   └── build.gradle.kts
├── long
│   ├── src
│   │   └── main
│   │       └── assets
│   └── build.gradle.kts
├── notlong
│   ├── src
│   │   └── main
│   │       └── assets
│   └── build.gradle.kts
└── settings.gradle.kts

:app build.gradle.kts is:

plugins {
    alias(libs.plugins.androidApplication)
    alias(libs.plugins.jetbrainsKotlinAndroid)
}

android {
    ...
    assetPacks.addAll(listOf(":long", ":notlong"))

    ...
    assets.srcDirs("src/main/assets", "long/src/main/assets", "notlong/src/main/assets")
    }

}

:long build.gradle.kts:

plugins {
    id("com.android.asset-pack")
}

assetPack {
    packName.set("long")
    dynamicDelivery {
        deliveryType = "on-demand"
    }
}

:notlong build.gradle.kts:

plugins {
    id("com.android.asset-pack")
}

assetPack {
    packName.set("notlong")
    dynamicDelivery {
        deliveryType = "on-demand"
    }
}

settings.gradle.kts:

...
include( "app")
include("long")
include("notlong")

What am I doing wrong?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video