Different string.xml files according to app Build Variants
Yes it's possible!
In your build.gradle you can add something like this:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
debug {
applicationIdSuffix ".debug"
minifyEnabled false
debuggable true
signingConfig signingConfigs.release
}
}
Then in your src
folder in your project you should have a folder called main, add one next to it called debug
. Den as long as you are building your debug flavour any resources in your debug folder will replace those in main which is the release folder.
Should look like this:
src/
main/
java/ -- all your java code
res/
...
values/
strings.xml
debug/
res/
...
values/
strings.xml
EDIT: The approaches from the two other answers works fine as well. But if you have a lot of strings keeping them as xml might be easier to handle.
It possible via your build.gradle file
buildTypes {
release {
resValue "string", "my_string", "some release value"
}
debug {
resValue "string", "my_string", "some debug value"
}
}
Then you can just use this value like @string/my_string
where you want