[英]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 values-fr
对于flavor1
和flavor2
常见,因此values
, values-fr
flavor2
和values-de
应该打包
flavor3
should only package values
and values-de
. flavor3
应该只打包values
和values-de
flavor3
。 So I need to exclude the values-fr
resource folder from the flavor3
only. 所以我只需要从flavor3
排除values-fr
资源文件夹。
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 . 您还可以在此处查看 ICU的国家/地区代码列表。
The final working solution is to include a language - in this case, only German (de): 最终的工作解决方案是包含一种语言 - 在这种情况下,只有德语(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 . 作为参考,您还可以在此处查看 ICU的国家/地区代码列表。
You can exclude those folders by using this snippet: 您可以使用此代码段排除这些文件夹:
sourceSets {
flavor3 {
main {
resources {
srcDir 'res'
exclude '**/values-fr/**'
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.