第一步:
在项目里新建一个keystone.properties文件用于保存密码,别名,和别名密码
内容如下:
KEYSTORE_PATH =../build_system/l***.jks
KEYSTORE_PASSWORD=***
ALIAS_TIANCHENG=***
ALIAS_TIANCHENG_PASSWORD=***
第二步:
在app的build.gradle文件的头部里配置
def keystorePropertiesFile =rootProject.file("keystore.properties")
def keystoreProperties =new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
第三步:
在andrid{}里配置
//签名
signingConfigs {
release {
storeFile file(keystoreProperties['KEYSTORE_PATH'])
storePassword keystoreProperties['KEYSTORE_PASSWORD']
keyAlias keystoreProperties['ALIAS_TIANCHENG']
keyPassword keystoreProperties['ALIAS_TIANCHENG_PASSWORD']
}
debug {
storeFile file(keystoreProperties['KEYSTORE_PATH'])
storePassword keystoreProperties['KEYSTORE_PASSWORD']
keyAlias keystoreProperties['ALIAS_TIANCHENG']
keyPassword keystoreProperties['ALIAS_TIANCHENG_PASSWORD']
}
}
第四步
buildTypes {
release{
signingConfig signingConfigs.release //添加此行代码
}
debug{
}
}
第五步
点击即可打包