Skip to content

Instantly share code, notes, and snippets.

@nadar71
Forked from navi25/HiddenApiKey.gradle
Created May 29, 2019 15:19
Show Gist options
  • Save nadar71/7da8bea635f05b360b8502caa57db021 to your computer and use it in GitHub Desktop.
Save nadar71/7da8bea635f05b360b8502caa57db021 to your computer and use it in GitHub Desktop.
//In local.properties
tmdb_api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
//In build.gradle (Module: app)
buildTypes.each {
Properties properties = new Properties()
properties.load(project.rootProject.file("local.properties").newDataInputStream())
def tmdbApiKey = properties.getProperty("tmdb_api_key", "")
it.buildConfigField 'String', "TMDB_API_KEY", tmdbApiKey
it.resValue 'string', "api_key", tmdbApiKey
}
//In your Constants File
var tmdbApiKey = BuildConfig.TMDB_API_KEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment