使用Gradle构建特定Android产品风格时,我可以排除区域资源(例如,值fr)吗? [英] Can I exclude regional resources (e.g. values-fr) when building a particular Android Product Flavor with gradle
问题描述
app
--src
| --main
| | --java
| | --res
| | - 可提取
| | - 价值
| | --values-fr
| | --values-de
|
| --flavor1
| | --res
| | - 可提取
|
| --flavor2
| | --res
| | - 可提取
|
| --flavor3
| --res
| - 可提取
对于 flavor1
和 flavor2 $ c $共用
值
,值-fr
和值-de
应该打包
flavor3
应该只打包值
和 values-de
。所以我需要仅从 flavor3
中排除 values-fr
资源文件夹。
我已经尝试了大量的组合,比如下面的组合,但是无法弄清楚,或者甚至是可能的。
sourceSets {
flavor3 {
res.exclude'values-fr / **'
res.exclude'values-fr /'
}
}
编辑
我发现这个工作解决方案只包含包含的德语,上面的例子使用:
productFlavors {
flavour3 {
resConfigs'de'//包含'-de'资源以及默认'值'
}
}
您也可以从ICU检查国家代码列表 here 。
最终的工作解决方案是包含一种语言 - 在这种情况下,只有德语(德):
productFlavors {
flavour3 {
resConfigs'de'//包括'-de'资源以及默认值'
}
}
作为参考,您也可以查看ICU的国家代码列表在这里。
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.
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.
这篇关于使用Gradle构建特定Android产品风格时,我可以排除区域资源(例如,值fr)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!