Skip to content

Instantly share code, notes, and snippets.

@vicky7230
Forked from navi25/HiddenApiKey.gradle
Created November 8, 2019 05:52
Show Gist options
  • Save vicky7230/0e9e37d716051281a20e7361a10a409e to your computer and use it in GitHub Desktop.
Save vicky7230/0e9e37d716051281a20e7361a10a409e 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