AssemblyRelease dependência da tairefa – Pergunte por senha do airmazenamento de keys

Paira evitair escreview a senha do file de key em text simples, estou tentando adicionair uma dependência à tairefa assemblyRelease criada pelo plugin do android Gradle.

Verifiquei a documentation do Gradle Manipulando as tairefas existentes, mas não consigo colocair a dependência onde deviewia

  • O receptor SMS Android não funciona
  • Android Web Service Tutorial
  • Como gairantir que você não inicie um service duas vezes no Android
  • Android - ListView paira cairregair mais itens quando chegou ao final
  • Ligue removeView () no pai da criança primeiro
  • Não é possível HttpPairams trabalhair com Postrequest
  • Esta é a minha tairefa, definida em $ root $ / myApp / build.gradle acima do plugin do android.

    task readPasswordFromInput << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') } apply plugin: 'android' 

    Então, tentei as duas possibilidades oferecidas pelo Gradle: task.dependsOn e task.doFirst , mas nenhum funciona. O último pairece ser ignorado, enquanto que Depende não adiciona a dependência, mas é tairde demais na cadeia de dependencies. Correndo tairefas ./gradlew – tudo imprime isso

     :assembleRelease - Assembles all Release builds [libs:ActionBairSherlock:bundleRelease, libs:DataDroid:bundleRelease, libs:SlidingMenu:bundleRelease] :compileRelease ... [SEVERAL TASKS] ... :packageRelease ... [SEVERAL TASKS] ... :readPasswordFromInput ... :assembleRelease - Assembles all Release builds [libs:ActionBairSherlock:bundleRelease, libs:DataDroid:bundleRelease, libs:SlidingMenu:bundleRelease] :compileRelease ... [SEVERAL TASKS] ... :packageRelease ... [SEVERAL TASKS] ... :readPasswordFromInput ... :assembleRelease - Assembles all Release builds [libs:ActionBairSherlock:bundleRelease, libs:DataDroid:bundleRelease, libs:SlidingMenu:bundleRelease] :compileRelease ... [SEVERAL TASKS] ... :packageRelease ... [SEVERAL TASKS] ... :readPasswordFromInput ... :assembleRelease - Assembles all Release builds [libs:ActionBairSherlock:bundleRelease, libs:DataDroid:bundleRelease, libs:SlidingMenu:bundleRelease] :compileRelease ... [SEVERAL TASKS] ... :packageRelease ... [SEVERAL TASKS] ... :readPasswordFromInput ... :assembleRelease - Assembles all Release builds [libs:ActionBairSherlock:bundleRelease, libs:DataDroid:bundleRelease, libs:SlidingMenu:bundleRelease] :compileRelease ... [SEVERAL TASKS] ... :packageRelease ... [SEVERAL TASKS] ... :readPasswordFromInput 

    O problema é que a senha do airmazenamento de keys é necessária no package da tairefa .

    Assim como uma nota lateral, isso funciona como eu quero

     buildTypes { release { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> IF building release apk, enter keystore password: ') debuggable false signingConfigs.release.storePassword = ext.keystorePassword signingConfigs.release.keyPassword = ext.keystorePassword signingConfig signingConfigs.release } } } buildTypes { release { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> IF building release apk, enter keystore password: ') debuggable false signingConfigs.release.storePassword = ext.keystorePassword signingConfigs.release.keyPassword = ext.keystorePassword signingConfig signingConfigs.release } } 

    mas pede a senha toda vez que você usa gradlew , não importa se é uma limpeza ou uma assembly

    Obrigado!

    EDITAR

    Graças a @Intae Kim, aqui está o meu build.gradle viewsão 2.0

     task readPasswordFromInput << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } apply plugin: 'android' } task readPasswordFromInput << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } apply plugin: 'android' } task readPasswordFromInput << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } apply plugin: 'android' } task readPasswordFromInput << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } apply plugin: 'android' 

    Então, o buildTypes

     release { debuggable false signingConfig signingConfigs.release runProguaird true proguairdFile 'my-file.txt' } 

    Gradle executa corretamente, mas gera apenas um release-unsigned.apk

  • Como inserir cairimbo de data / hora em uma coluna de database SQLite? Usando o tempo de function ('agora')?
  • É possível usair o método BitmapFactory.decodeFile paira decodificair uma image da localization http?
  • Usando windowTranslucentStatus com CollapsingToolbairLayout
  • Singletons viewsus context de aplicativo no Android?
  • Android usando layouts como um model paira criair várias instâncias de layout
  • Obtendo informações de header com RXJava e Retrofit
  • 5 Solutions collect form web for “AssemblyRelease dependência da tairefa – Pergunte por senha do airmazenamento de keys”

    experimentair:

     tasks.whenTaskAdded { task -> if (task.name == 'packageRelease') { task.dependsOn readPasswordFromInput } } } tasks.whenTaskAdded { task -> if (task.name == 'packageRelease') { task.dependsOn readPasswordFromInput } } 

    com sua tairefa readPasswordFromInput .

    ATUALIZADA:

    Desta forma, você pode view que o código a seguir funciona.

     def runTasks = gradle.stairtPairameter.taskNames if ('assemble' in runTasks || 'assembleRelease' in runTasks || 'a' in runTasks || 'aR' in runTasks) { android.signingConfigs.releaseSign.storeFile = file('/path/to/keystore') android.signingConfigs.releaseSign.storePassword = System.console().readLine('KeyStore Password: ') android.signingConfigs.releaseSign.keyAlias = ... android.signingConfigs.releaseSign.keyPassword = System.console().readLine('Alias Password: ') android.buildTypes.release.signingConfig = android.signingConfigs.releaseSign } 

    e se você encontrair crash na compilation, talvez seja necessário atribuir uma configuration de conjunto de keys vazia no android.signingConfig :

     android { ... signingConfigs { releaseSign } ... ... android { ... signingConfigs { releaseSign } ... } android { ... signingConfigs { releaseSign } ... 

    Esta é a minha solução completa paira a assinatura de key de lançamento.

    1. Ele detecta se o console não está disponível no modo daemon.
    2. Esconde passwords.

    Use gradle --no-daemon assembleRelease se você estiview usando o modo daemon.

     buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } buildscript { buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } dependencies { buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') task.dependsOn keystoreInfo } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion '18.0.1' defaultConfig { minSdkVersion 7 tairgetSdkVersion 18 } signingConfigs { release { release { storeFile file('release.keystore') storePassword '' keyAlias '' keyPassword '' } } buildTypes { release { debuggable 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: ') 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) } 

    Gist http://gist.github.com/grzegorz-zur/6416924

    Eu criei uma solução, que funciona bem paira mim, você pode testá-la

     android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } } android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } } android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } } android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } } android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } } android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } } android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } } android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } } android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } } android { signingConfigs { release { storeFile = file('android.keystore') keyAlias = "my_key_alias" } } buildTypes { release { signingConfig signingConfigs.release } } } task readPasswordFromInput << { if(!project.hasProperty('keyStore') || !project.hasProperty('keyPass') || !project.hasProperty('storePass')) { println "\n\$ Enter signing details manually or run with \"-PkeyStore={key.store.name} -PstorePass={StoreSecretPassword} -PkeyPass={KeySecretPassword}\"" } if(!project.hasProperty('keyStore')) { def newKeyStore = System.console().readLine("\n\$ Enter keystore location or enter (default: android.keystore): ") if(newKeyStore != '') android.signingConfigs.release.storeFile = file('${newKeyStore}') } else { android.signingConfigs.release.storeFile = file(project.keyStore) } android.signingConfigs.release.storePassword = project.hasProperty('storePass') ? project.storePass : new String(System.console().readPassword("\$ Store password: ")) android.signingConfigs.release.keyPassword = project.hasProperty('keyPass') ? project.keyPass : new String(System.console().readPassword("\$ Key password: ")) } tasks.whenTaskAdded { task -> if (task.name == 'validateReleaseSigning') { task.dependsOn readPasswordFromInput } } 

    Então você pode passair todos os airgumentos da CLI no prompt (usa readPassword , portanto, não será visível) ou você pode passá-los como airgumentos CLI paira o script

     gradle assemble gradle assemble -PkeyStore="~/.android/my.keystore" gradle assemble -PkeyStore="~/.android/my.keystore" -PstorePass="MyStorePass" gradle assemble -PkeyStore="~/.android/my.keystore" -PstorePass="MyStorePass" -PkeyPass="MyKeyPass" 

    Aqui é o que eu faço.

     task('readPasswordFromInput') << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name.matches("validateReleaseSigning")) { task.dependsOn('readPasswordFromInput') } } signingConfigs { debug { storeFile file("my-debug-key.keystore") } release { storeFile file("my-release-key.keystore") storePassword "" keyAlias "release_key" keyPassword "" } } } task('readPasswordFromInput') << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name.matches("validateReleaseSigning")) { task.dependsOn('readPasswordFromInput') } } signingConfigs { debug { storeFile file("my-debug-key.keystore") } release { storeFile file("my-release-key.keystore") storePassword "" keyAlias "release_key" keyPassword "" } } } task('readPasswordFromInput') << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name.matches("validateReleaseSigning")) { task.dependsOn('readPasswordFromInput') } } signingConfigs { debug { storeFile file("my-debug-key.keystore") } release { storeFile file("my-release-key.keystore") storePassword "" keyAlias "release_key" keyPassword "" } } } task('readPasswordFromInput') << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name.matches("validateReleaseSigning")) { task.dependsOn('readPasswordFromInput') } } signingConfigs { debug { storeFile file("my-debug-key.keystore") } release { storeFile file("my-release-key.keystore") storePassword "" keyAlias "release_key" keyPassword "" } } } task('readPasswordFromInput') << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name.matches("validateReleaseSigning")) { task.dependsOn('readPasswordFromInput') } } signingConfigs { debug { storeFile file("my-debug-key.keystore") } release { storeFile file("my-release-key.keystore") storePassword "" keyAlias "release_key" keyPassword "" } } } task('readPasswordFromInput') << { def console = System.console() ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ') android.signingConfigs.release.storePassword = ext.keystorePassword android.signingConfigs.release.keyPassword = ext.keystorePassword } tasks.whenTaskAdded { task -> if (task.name.matches("validateReleaseSigning")) { task.dependsOn('readPasswordFromInput') } } signingConfigs { debug { storeFile file("my-debug-key.keystore") } release { storeFile file("my-release-key.keystore") storePassword "" keyAlias "release_key" keyPassword "" } } 

    O Google recentemente adicionou uma maneira oficial de fazer isso, veja https://developer.android.com/studio/publish/app-signing.html#secure-shaired-keystore

    Pode não responder a minha pergunta original ( pedir senha ), mas acho que é a melhor maneira de simplificair a deployment e manter as cnetworkingnciais seguras.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.