调试变体中的字符串资源不起作用



我曾经在 gradle 中将应用程序名称定义为资源:

android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "lelisoft.com.lelimath"
resValue 'string', 'app_name', 'LeliMath'
}
buildTypes {
debug {
applicationIdSuffix ".debug"
resValue 'string', 'app_name', 'LeliMath DEV'
}
}

然后我发现需要本地化,所以我从 gradle 中删除了所有resValue并在strings.xml中定义:

appsrcdebugresvaluesstrings.xml
<string name="app_name">LeliMath DEV</string>
appsrcmainresvaluesstrings.xml
<string name="app_name">Leli Math</string>
appsrcmainresvalues-csstrings.xml
<string name="app_name">Leli Matematika</string>

当我在 Studio 中编译我的应用程序时,它会显示 Leli Matematika。我期待LeliMath DEV。我 https://stackoverflow.com/a/37579475/1639556 受到这个答案的启发。

您将通过将字符串放在这里来获得它。

appsrcdebugresvalues-csstrings.xml
<string name="app_name">LeliMath DEV</string>

希望有帮助:(

最新更新