1.在app/build.gradle文件中增加signingConfigs字段
apply plugin: ‘com.android.application‘
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.test.example"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
File strFile = new File("../../Keystore/Debug/debug.jks")
storeFile file(strFile)
storePassword "storeDebug1234567890"
keyAlias "debugkey"
keyPassword "aliasDebug1234567890"
//println strFile.absolutePath;
}
release {
File strFile = new File("../../Keystore/Release/release.jks")
storeFile file(strFile)
storePassword "storeRelease1234567890"
keyPassword "keyRelease1234567890"
keyAlias "releasekey"
// println strFile.absolutePath;
}
}
buildTypes {
release {
signingConfig signingConfigs.release #缺少这段,或者buildtypes在signingconfigs签名
runProguard false
proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
}
}
}
ps:注意这段的证书路径以及密码根据自己的实际情况进行修改
我们这里就时配置了证书,但是发现还是不能打包release,其实是缺少了signingConfig signingConfigs.release
重新打包就可以正常生成app-release.apk了。