比如签名时的密码和别名,需在gradle.properties中进行保存,因其并不会加入版本控制中。
// 例
signingConfigs {
release {
storeFile file("myapp.keystore")
storePassword "password123"
keyAlias "thekey"
keyPassword "password789"
}
}
#将敏感信息写入gradle.properties
KEYSTORE_PASSWORD=password123
KEY_PASSWORD=password789
# ----------------------------------------
# 最终如下
#release为在Signing中配置的名字
signingConfigs {
release {
try {
storeFile file("myapp.keystore")
storePassword KEYSTORE_PASSWORD
keyAlias "thekey"
keyPassword KEY_PASSWORD
}
catch (ex) {
throw new InvalidUserDataException("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.")
}
}
}