Created
April 6, 2015 07:37
-
-
Save curioustechizen/9f7d745f9f5f51355bd6 to your computer and use it in GitHub Desktop.
Android: Loading API Keys and other secrets from properties file using gradle
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
buildTypes { | |
applicationVariants.all { variant -> | |
variant.buildConfigField "String", "API_KEY", "\""+getApiKey()+"\"" | |
} | |
} | |
def getApiKey(){ | |
def Properties props = new Properties() | |
props.load(new FileInputStream(new File('secrets.properties'))) | |
return props['API_KEY'] | |
} |
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=my_awesome_api_key |
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
String apiKey = BuildConfig.API_KEY |
Map API key and fabric API key that we have to pass in Android Manifest at the time of reverse engineering we are unable to hide these api keys even though we declare them in buid gradle.
.Correct. See this comment
What is the solution for that?
@ritualapplocum Did you read the whole conversation? Your question is answered in the comments above.
@ritualapplocum Did you read the whole conversation? Your question is answered in the comments above.
yes I have already implemented it in build gradle and using those values in manifest but again when we decompile the code manifest is still displaying those api keys
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Correct. See this comment