Reputation: 31
I need to add different assets for each build variants in Android Studio and i'm trying to use Play Asset Delivery, unfortunately there its no documentation or at least i could not find it . Its this even possible ?
My plan its to replace the "old" delivery system of assets using obb , and its an app not a game .
Upvotes: 2
Views: 395
Reputation: 31
Incredibly it seems like there's no way to set the assetPacks
per flavor in build.gradle!
We have a lot of assetPacks, and a bunch of flavors, so we added a map that maps flavor name to assetPacks
, and set assetPacks
from that.
From our build.gradle:
// figure out what our current flavor is to use to set the asset packs
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()
Pattern pattern = Pattern.compile("([A-Z][a-z]+)(Release|Debug)")
Matcher matcher = pattern.matcher( tskReqStr )
String currentflavor = ""
if( matcher.find() )
currentflavor = matcher.group(1).toLowerCase()
if ( AssetPacks[currentflavor] ) {
assetPacks = AssetPacks[currentflavor]
// sanity check
println AssetPacks[currentflavor]
}
else if ( currentflavor ) {
// sanity check
println "NO ASSET PACKS"
}
Upvotes: 3