Last active
March 16, 2023 17:11
-
-
Save ramonrabello/b88bd8619407e3a42d02fb7cfb32b6a9 to your computer and use it in GitHub Desktop.
Example of how to use build fields for different build types.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
// defaultConfig goes here | |
buildTypes { | |
debug { | |
buildConfigField "String", 'BASE_URL', "https://dev-api.yourbackend.com" | |
} | |
staging { | |
buildConfigField "String", 'BASE_URL', "https://stg-api.yourbackend.com" | |
} | |
release { | |
buildConfigField "String", 'BASE_URL', "https://api.yourbackend.com" | |
} | |
} | |
} |
It is worth mentioning here that after these changes if your BuildConfig.java
does not get updated then you should clean project and rebuild the project.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found that I had to escape the URLS as ""https://dev-api.yourbackend.com\"" to get it to work.