Sign APK without putting keystore info in build.gradle

后端 未结 12 991
栀梦
栀梦 2020-11-28 17:51

I am trying to setup signing process so that keystore password and key password are not stored in the project\'s build.gradle file.

Cur

12条回答
  •  广开言路
    2020-11-28 18:19

    You can request passwords from the command line:

    ...
    
    signingConfigs {
      if (gradle.startParameter.taskNames.any {it.contains('Release') }) {
        release {
          storeFile file("your.keystore")
          storePassword new String(System.console().readPassword("\n\$ Enter keystore password: "))
          keyAlias "key-alias"
          keyPassword new String(System.console().readPassword("\n\$ Enter keys password: "))
        } 
      } else {
        //Here be dragons: unreachable else-branch forces Gradle to create
        //install...Release tasks.
        release {
          keyAlias 'dummy'
          keyPassword 'dummy'
          storeFile file('dummy')
          storePassword 'dummy'
        } 
      }
    }
    
    ...
    
    buildTypes {
      release {
    
        ...
    
        signingConfig signingConfigs.release
      }
    
      ...
    }
    
    ...
    

    This answer previously appeared: https://stackoverflow.com/a/33765572/3664487

提交回复
热议问题