[英]how can we force locale in android app depending on buildType in gradle
I want to use only english language in release build and multiple languages in debug build. 我只想在发布版本中使用英语,而在调试版本中使用多种语言。 I am able to achieve this using ProductFlavour but not with buildType. 我可以使用ProductFlavour来实现,但不能通过buildType来实现。
productFlavors {
english {
resConfigs "en"
}
french {
resConfigs "en", "fr"
}
}
I'm using resConfig.. but it cant be used under buildTypes. 我正在使用resConfig ..但不能在buildTypes下使用。 If i try using it under buildTypes, build fails and I'm getting below error: 如果我尝试在buildTypes下使用它,则构建失败,并且出现以下错误:
Gradle DSL does not found: resConfigs() 找不到Gradle DSL:resConfigs()
Any help will be really appreciated 任何帮助将不胜感激
one more question in the same line. 同一行还有一个问题。 I have scenario, where I need to use default values only when QA_BUILD is false. 我有方案,仅在QA_BUILD为false时才需要使用默认值。 My build.gradle looks like this: 我的build.gradle看起来像这样:
debug { buildConfigField "boolean", "QA_BUILD", "false" } integration { buildConfigField "boolean", "QA_BUILD", "false" } release { buildConfigField "boolean", "QA_BUILD", "true" } 调试{buildConfigField“ boolean”,“ QA_BUILD”,“ false”}集成{buildConfigField“ boolean”,“ QA_BUILD”,“ false”}发布{buildConfigField“ boolean”,“ QA_BUILD”,“ true”}
If you want to have only the default (English) values, and you want to control that through the build process you can exclude the localized folders (ie values-fr
) from the release build. 如果只希望使用默认值(英文),并且希望通过构建过程进行控制,则可以从发行版构建中排除本地化文件夹(即values-fr
)。
Just put the folders you only want to be compiled for debug
in src/debug/...
只需将您只想编译供debug
的文件夹放在src/debug/...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.