Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I exclude regional resources (e.g. values-fr) when building a particular Android Product Flavor with gradle

Say I have this directory structure:

app
--src
   |--main
   |   |--java
   |   |--res
   |       |--drawable
   |       |--values
   |       |--values-fr
   |       |--values-de
   |
   |--flavor1
   |   |--res
   |       |--drawable
   |
   |--flavor2
   |   |--res
   |       |--drawable
   |
   |--flavor3
       |--res
           |--drawable

values-fr is common for both flavor1 and flavor2, and so values, values-fr and values-de should get packaged

flavor3 should only package values and values-de. So I need to exclude the values-fr resource folder from the flavor3 only.

I've tried loads of combinations such as those below, but cannot figure it out, or even if it's possible.

sourceSets {
    flavor3 {
        res.exclude 'values-fr/**'
        res.exclude 'values-fr/'
    }
}

EDIT

I found this working solution to include only German for the above example using:

productFlavors {
    flavour3 {
        resConfigs 'de' // include '-de' resources, along with default 'values'
    }
}

You can also check the list of country codes from ICU here.

like image 279
Fifer Sheep Avatar asked Sep 11 '14 15:09

Fifer Sheep


1 Answers

The final working solution is to include a language - in this case, only German (de):

productFlavors {
    flavour3 {
        resConfigs 'de' // include '-de' resources, along with default 'values'
    }
}

As a reference, you can also check the list of country codes from ICU here.

like image 195
Fifer Sheep Avatar answered Oct 13 '22 12:10

Fifer Sheep