Skip to content

Instantly share code, notes, and snippets.

@root-ansh
Created August 16, 2020 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save root-ansh/63e1885b8d88663730c1644475b0a928 to your computer and use it in GitHub Desktop.
Save root-ansh/63e1885b8d88663730c1644475b0a928 to your computer and use it in GitHub Desktop.
Securing keys-Medium
// app/build.gradle
plugins {
...
}
android {
...
defaultConfig {
...
}
buildTypes {
debug{
def credsFile = rootProject.file("secure\\debug_creds.properties")
def prop = new Properties()
prop.load(new FileInputStream(credsFile))
buildConfigField('String', 'KEY_USER', prop['KEY_USER']) // always use single quotes here
}
release {
def credsFile = rootProject.file("secure\\release_creds.properties")
def prop = new Properties()
prop.load(new FileInputStream(credsFile))
buildConfigField('String', 'KEY_USER', prop['KEY_USER']) // always use single quotes here
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
...
}
dependencies {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment