I have an Android Studio project which uses NDK and CMake and externalNativeBuild. To reduce packet size I have several flavors for different texture compression formats. There are no code changes, i.e. all the resulting APKs are using exactly the same code.
productFlavors {
ETC2 {
manifestPlaceholders = [supportedTexture: "GL_OES_compressed_ETC2_RGB8_texture"]
}
DXT {
manifestPlaceholders = [supportedTexture: "GL_EXT_texture_compression_dxt1"]
}
ATC {
manifestPlaceholders = [supportedTexture: "GL_AMD_compressed_ATC_texture"]
}
//...and list goes on...
}
What this means in practice is that I have a Copy task which checks the current flavor and copies the correct texture pack into the APK. The getCurrentFlavor()
function is copied from How to get current flavor in gradle:
task copyTexSD(type: Copy) {
def currentFlavor = getCurrentFlavor()
if(currentFlavor == "etc2") {
from 'bin/tex/ETC2.bin'
}
else if(currentFlavor == "dxt") {
from 'bin/tex/DXT.bin'
}
else if(currentFlavor == "atc") {
from 'bin/tex/ATC.bin'
}
//...
into 'src/main/assets/tex'
}
To build averything I use the following batch command:
call gradlew clean
call gradlew assembleETC2Release
call gradlew assembleDXTRelease
call gradlew assembleATCRelease
This works otherwise well, but for some reason the texture packets which are copied to previous APKs are also included in the subsequent APKs like this:
- app-ETC2-release.apk contains only ETC2.bin file
- app-DXT-release.apk contains DXT.bin and ETC2.bin
- app-ATC-release.apk contains ATC.bin, DXT.bin and ETC2.bin
Why the build process includes assets from previous Gradle task? How can I make the build process to have only one texture file per APK?