问题描述
假设我有这个目录结构:
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 对于 flavor1 和 flavor2 都是通用的,因此 values、values-fr 和 values-de 应该被打包
values-fr is common for both flavor1 and flavor2, and so values, values-fr and values-de should get packaged
flavor3 应该只打包 values 和 values-de.所以我只需要从 flavor3 中排除 values-fr 资源文件夹.
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/' } }
<小时>
编辑
对于上面的示例,我发现这个包含仅德语的工作解决方案使用:
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' } }
您还可以在这里查看ICU的国家代码列表.
You can also check the list of country codes from ICU here.
推荐答案
最终的工作解决方案是包含一种语言 - 在这种情况下,只有德语(de):
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' } }
作为参考,您还可以查看 ICU 这里的国家代码列表.
As a reference, you can also check the list of country codes from ICU here.