Last active
August 11, 2017 16:33
-
-
Save kikermo/040b371a376e2c1c26d3096cbd3886aa to your computer and use it in GitHub Desktop.
How to use a properties file to store keys instead of including them in build.gradle file
This file contains hidden or 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 { | |
... | |
def keys = new Properties() | |
file("../keys.properties").withInputStream { | |
stream -> keys.load(stream) | |
} | |
productFlavors { | |
development{ | |
buildConfigField "String", "API_KEY", "\"" + keys.API_KEY_DEVELOPMENT + "\"" | |
} | |
staging { | |
buildConfigField "String", "API_KEY", "\"" + keys.API_KEY_STAGING + "\"" | |
} | |
production { | |
buildConfigField "String", "API_KEY", "\"" + keys.API_KEY_PRODUCTION + "\"" | |
} | |
} | |
... | |
} |
This file contains hidden or 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
API_KEY_DEVELOPMENT = d3v3l0pm3ntKey | |
API_KEY_STAGING = st4gingk3y | |
API_KEY_PRODUCTION = pr0ducti0nK3y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment