Skip to content

Instantly share code, notes, and snippets.

@grzegorz-zur
Last active December 22, 2015 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save grzegorz-zur/6416924 to your computer and use it in GitHub Desktop.
Save grzegorz-zur/6416924 to your computer and use it in GitHub Desktop.
signing release APK - complete Gradle build script
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
tasks.whenTaskAdded { task ->
if (task.name == 'validateReleaseSigning')
task.dependsOn keystoreInfo
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
signingConfigs {
release {
release {
storeFile file('release.keystore')
storePassword ''
keyAlias ''
keyPassword ''
}
}
buildTypes {
release {
debuggable false
jniDebugBuild false
signingConfig signingConfigs.release
}
}
}
}
task keystoreInfo << {
def console = System.console()
if (console == null)
throw new IllegalStateException('no console available, use --no-daemon flag')
def storeFile = console.readLine('Keystore file: ')
def storePassword = console.readPassword('Keystore password: ')
def keyAlias = console.readLine('Key alias: ')
def keyPassword = console.readPassword('Key password: ')
android.signingConfigs.release.storeFile = file(storeFile)
android.signingConfigs.release.storePassword = new String(storePassword)
android.signingConfigs.release.keyAlias = keyAlias
android.signingConfigs.release.keyPassword = new String(keyPassword)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment