I want to assign a value to a string in string.xml different values depending on the Build Variant/buildType. I imagine something like this:
res/values-debug/string.xml <string name="my_string">some debug value</string> res/values-release/string.xml <string name="my_string">some release value</string>
but I don't see anything like this out there. Is this possible?
Yes it's possible!
In your build.gradle you can add something like this:
Then in your
src
folder in your project you should have a folder called main, add one next to it calleddebug
. 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:
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.