0

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)?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Jakob Ulbrich
  • 133
  • 1
  • 7
  • Maybe this [SO post](https://stackoverflow.com/questions/25791469/can-i-exclude-regional-resources-e-g-values-fr-when-building-a-particular-and) is helpful ? – Bö macht Blau Jan 23 '18 at 19:47
  • I already came across this post, but I think it does not work to easily exclude all higher API configurations with this approach. – Jakob Ulbrich Jan 25 '18 at 15:36

0 Answers0