Skip to content

Instantly share code, notes, and snippets.

@AdamMc331
Created August 12, 2021 15:06
Show Gist options
  • Save AdamMc331/ab5e10d659c48a7172f111abacda6bd7 to your computer and use it in GitHub Desktop.
Save AdamMc331/ab5e10d659c48a7172f111abacda6bd7 to your computer and use it in GitHub Desktop.
Short example of storing API Keys for an Android repo.
local.properties
# Don't forget to ignore this from your source control
android {
Properties properties = new Properties()
properties.load(project.rootProject.file("local.properties").newDataInputStream())
defaultConfig {
buildConfigField("String", "MY_API_KEY", properties.getProperty("APIKey"))
}
}
APIKey="MyAPIKeyHere"
class MainActivity {
val apiKey = BuildConfig.MY_API_KEY
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment