我喜欢在我的构建文件中保留密码。因此我创建了一个我加载的属性文件
def keystorePropertiesFile = rootProject.file("./local.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
然后我像这样定义signingConfigs:
signingConfigs {
releaseSigning {
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['keystore.live.storepassword']
keyAlias = keystoreProperties['keystore.live.keyalias']
keyPassword = keystoreProperties['keystore.live.keypassword']
}
debugSigning {
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['keystore.debug.storepassword']
keyAlias = keystoreProperties['keystore.debug.keyalias']
keyPassword = keystoreProperties['keystore.debug.keypassword']
}
}
这不适用于菜单选项“创建签名的 apk”,因此我创建了风味:
productFlavors {
mydebug {
signingConfig signingConfigs.debugSigning
}
myrelease {
signingConfig signingConfigs.releaseSigning
}
}
现在签名配置与工具栏上的运行按钮一起使用。对于默认密钥库,local.properties 看起来像
ndk.dir=/opt/sdk/ndk-bundle
sdk.dir=/opt/sdk
storeFile=/home/christine/.android/debug.keystore
keystore.debug.storepasswd=android
keystore.debug.keyalias=androiddebugkey
keystore.debug.keypassword=android
keystore.live.storepasswd=android
keystore.live.keyalias=androiddebugkey
keystore.livetest.keypassword=android
在您的 Jenkins 构建脚本中,您需要创建一个从 local.properties 到属性文件在构建服务器上的位置的符号链接。