我曾经在 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
中定义:
app\src\debug\res\values\strings.xml
<string name="app_name">LeliMath DEV</string>
app\src\main\res\values\strings.xml
<string name="app_name">Leli Math</string>
app\src\main\res\values-cs\strings.xml
<string name="app_name">Leli Matematika</string>
当我在 Studio 中编译应用程序时,它显示 Leli Matematika。我期待 LeliMath DEV。我受到这个答案的启发https://stackoverflow.com/a/37579475/1639556 .
最佳答案
您可以通过将字符串放在这里来获取它。
app\src\debug\res\values-cs\strings.xml
<string name="app_name">LeliMath DEV</string>
希望有帮助:)
关于android - 调试变体中的字符串资源不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45887587/