Skip to content

Instantly share code, notes, and snippets.

@SleeplessByte
Created January 24, 2015 23:51
Show Gist options
  • Save SleeplessByte/89c90f702c0f2fdc2b12 to your computer and use it in GitHub Desktop.
Save SleeplessByte/89c90f702c0f2fdc2b12 to your computer and use it in GitHub Desktop.
Android Studio - How to gitignore your signing.
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile [...]
}
android {
// Add a gradle.properties to your root to make this workd:
//compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
//buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 7
//targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
//versionName project.VERSION_NAME
//versionCode Integer.parseInt(project.VERSION_CODE)
}
signingConfigs { release }
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
// Add a file signing.properties
File propFile = file('signing.properties');
if (propFile.exists()) {
def Properties props = new Properties()
props.load(new FileInputStream(propFile))
if (props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
} else {
android.buildTypes.release.signingConfig = null
}
} else {
android.buildTypes.release.signingConfig = null
}
VERSION_NAME=1.0.0
VERSION_CODE=1
ANDROID_BUILD_TARGET_SDK_VERSION=19
ANDROID_BUILD_TOOLS_VERSION=21.1.2
ANDROID_BUILD_SDK_VERSION=21
STORE_FILE=/path/to/your.keystore
STORE_PASSWORD=yourkeystorepass
KEY_ALIAS=projectkeyalias
KEY_PASSWORD=keyaliaspassword
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment