我曾经在 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'
}
}
然后我发现需要本地化,所以我resValue
从 gradle 中删除了所有内容并在 in 中定义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。