Precursor: I want to localize the App name(using string resources)
and at the same time add build type suffix("DEBUG") from gradle file.
Here I am Trying to concatenate string resource "app_name" and gradle variable "AppNameSuffix"
Expected app name :
for product flavor "all" - "My application DEBUG"
for product flavor "china" - "My Chinese application DEBUG"
and subsequent build type suffixed for "RELEASE" and "CANARY"
build.gradle:
buildTypes {
debug {
manifestPlaceholders = [AppNameSuffix: "DEBUG"]
...
}
release{
manifestPlaceholders = [AppNameSuffix: "RELEASE"]
...
}
canary{
manifestPlaceholders = [AppNameSuffix: "CANARY"]
}
}
productFlavors {
china {
applicationId "com.myapplication.china"
}
all {
//default
applicationId "com.myapplication.all"
}
}
Manifest :
<application
...
android:label="@{@string/app_name(${AppNameSuffix})}">
...
</application>
error at "$" symbol while evaluating gradle variable
main/res/string.xml :
<string name="app_name">My application %s</string>
china/res/string.xml :
<string name="app_name">My Chinese application %s</string>
References: