Using Android Studio, you can define build variants, and define strings in that case:
Generate Java Constants
Plugin version greater than 0.7.x (current method)
android {
buildTypes {
debug {
buildConfigField "int", "FOO", "42"
buildConfigField "String", "FOO_STRING", "\"foo\""
}
release {
buildConfigField "int", "FOO", "52"
buildConfigField "String", "FOO_STRING", "\"bar\""
}
}
}
Plugin version less than 0.7 (old)
android {
buildTypes {
debug {
buildConfig "public final static int FOO = 42;"
}
release {
buildConfig "public final static int FOO = 52;"
}
}
}
You can access them with BuildConfig.FOO
Generate Android resources (since plugin 0.8.3)
android {
buildTypes {
debug{
resValue "string", "app_name", "My App Name Debug"
}
release {
resValue "string", "app_name", "My App Name"
}
}
}
You can access them in the usual way with @string/app_name
or R.string.app_name
source: https://stackoverflow.com/a/17201265/1096905 (All credits to him, i just copy&paste)