Created
August 12, 2021 15:06
-
-
Save AdamMc331/ab5e10d659c48a7172f111abacda6bd7 to your computer and use it in GitHub Desktop.
Short example of storing API Keys for an Android repo.
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
local.properties | |
# Don't forget to ignore this from your source control |
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
android { | |
Properties properties = new Properties() | |
properties.load(project.rootProject.file("local.properties").newDataInputStream()) | |
defaultConfig { | |
buildConfigField("String", "MY_API_KEY", properties.getProperty("APIKey")) | |
} | |
} |
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
APIKey="MyAPIKeyHere" |
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
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