Every time i release my app i change all my url strings and some keys from testing to production. The way I do it is just comment out the testing strings before i release. Is there a better way to handle strings based on the build type ?
TL;DR: If a library module includes a flavor dimension that the app flavor does not, then use missingDimensionStrategy to specify default flavors from the missing dimension. More generally, you can use this any time a consumed module includes a flavor that the consumer module does not.
Build types define certain properties that Gradle uses when building and packaging your app, and are typically configured for different stages of your development lifecycle.
BuildConfigField. Gradle allows buildConfigField lines to define constants. These constants will be accessible at runtime as static fields of the BuildConfig class. This can be used to create flavors by defining all fields within the defaultConfig block, then overriding them for individual build flavors as needed.
Assuming you use Android Studio, by default the system creates a basic release
and debug
flavor. So if you add a debug
and release
folder in the app/src
folder of your project you can declare separate values there.
So your structure should be like this:
project -app -src -debug -java ... -res -values -strings.xml -release -java ... -res -values -strings.xml -main -java ... -res -values -strings.xml
I should also add that if you have a string which isn't defined in either of the debug
or the release
folder that it will fallback to your main
folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With