问题描述
假设我有这个目录结构:
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.
这篇关于使用 gradle 构建特定的 Android Product Flavor 时,我可以排除区域资源(例如 values-fr)吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)