I am developing an android app. I need to use two google console projects for my dev environment and production. But there's a strings.xml file and I can not change their strings according to the environment. Can anyone help me?
Asked
Active
Viewed 971 times
0
-
Does [this post](https://stackoverflow.com/questions/35939270/is-it-possible-to-load-different-stringxml-values-in-android) help you? – Ricky Mo Dec 06 '21 at 06:13
-
yes. It is also correct. Thank you – sanjeewa priyanath Dec 06 '21 at 16:27
1 Answers
0
If you are asking to change String values depending on debug or release apk. Then you should put values in Gradle (build.gradle Module) rather than in String.xml values like this.
buildTypes {
release {
resValue("string", "id", "your production value here")
}
debug {
resValue("string", "id", "your development value here")
}
}
and you can get this value in code like this.
context.getString(R.string.id);
This will show after you rebuild the project after adding the values in Gradle as these are generated compileTime.
I hope this helps and please mind my English as it's not my native language.

Shehzad Nazir
- 16
- 1
-
hi.. Is there a way to do the same for google-service.json file? – sanjeewa priyanath Dec 06 '21 at 16:26
-
Forthat purpose https://stackoverflow.com/questions/30772201/google-services-json-for-different-productflavors This should be able to help you. – Shehzad Nazir Dec 07 '21 at 17:27