我用的是这样的东西.
我的app根文件夹中有一个signing.properties.
STORE_FILE=xxxx
STORE_PASSWORD=xxx
KEY_ALIAS=xxx
KEY_PASSWORD=xxx
此版本控制下未启用此文件.
当然你可以改变文件夹.
然后在你的build.gradle中你可以使用这样的东西:
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
def Properties props = new Properties()
def propFile = file('../signing.properties')
if (propFile.canRead()){
props.load(new FileInputStream(propFile))
if (props!=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
} else {
android.buildTypes.release.signingConfig = null
}
}else {
android.buildTypes.release.signingConfig = null
}
如果更改文件夹,则必须更改此行:
def propFile = file('../signing.properties')