简介
在开发中有时需要在debug模式使用正式签名,比如微信的支付功能必须需要正式签名,将debug签名配置为正式签名,然后就可以开心的run了,再也不用担心run起来一些以签名作为授权的sdk无法正常使用!
步骤
- 将keystore拷入项目目录下供gradle配置使用
- 在signingConfigs中配置签名密码
- 在buildTypes中使用已经配置好的signingConfigs
代码
signingConfigs {
release {
storeFile file("yourkeystore.jks")//keystore的路径
storePassword "你的keystore密码"
keyAlias "你的别名"
keyPassword "你的别名密码"
}
debug {
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true//启动代码混淆
zipAlignEnabled true//Zipalign优化
shrinkResources true// 移除无用的resource文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.release
}
}