How can I exclude resource folders that contain resources for higher API Levels from my APK to keep its size minimal?
Currently I have PNG files in my drawable folder and WebP files with transparency (which are supported from API level 18) in drawable-v18. I have specified 2 flavors: One for newer APIs that make use of the drawable-v18 resources and one to support legacy devices lower than API 18.
flavorDimensions "api"
productFlavors {
common {
dimension "api"
minSdkVersion 18
}
legacy {
dimension "api"
maxSdkVersion 17 // This does not exclude the folders for higher APIs
}
}
The common flavor correctly only contains the v18 drawables. But the legacy flavor contains both drawable and drawable-18. I thought specifying a maxSdkVersion would remove the v18 version, but that was not the fact.
How can I easily remove all resource configurations with API 18+ from my legacy flavor from within my gradle file? Or do I need to put the drawables in the specific flavor folder (I want to avoid that)?