Add buildConfigFields from .properties file Create file in folder: D:\MyProject\app\properties\api\debug.properties
Last active
November 1, 2018 08:58
-
-
Save Kolyall/5c9950b6da5153adfc056de9252e73be to your computer and use it in GitHub Desktop.
Add buildConfigFields from .properties file via code
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
defaultConfig { | |
... | |
//region ---Adding properties/payment/release.properties KEYs to BuildConfig--- | |
def paymentPropsFile = file('properties/api/debug.properties') | |
if (paymentPropsFile.canRead()) { | |
Properties properties = new Properties() | |
properties.load(new FileInputStream(paymentPropsFile)) | |
for(String key : properties.stringPropertyNames()) { | |
def propertyValue = properties.getProperty(key) | |
def propertyParams = propertyValue.split(";") | |
buildConfigField "${propertyParams[0]}", "${key}", "${propertyParams[1]}" | |
} | |
} else { | |
throw new Exception("Could not read properties/api/debug.properties!") | |
} | |
//endregion | |
} |
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
#Tue Sep 05 14:02:16 EEST 2017 | |
API_VERSION=int;2 | |
SECRET_PART=String;"AnyString" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment