在android7.0中谷歌更新了签名的方式 APK signature scheme v2
https://developer.android.com/about/versions/nougat/android-7.0.html#apk_signature_v2
导致使用多渠道打包工具在7.0的设备上安装失败,所以要对多渠道打包的方式进行更新
signingConfigs {
release {
v2SigningEnabled false
//添加如下keystore信息
storeFile file("xxx")
storePassword "xxx"
keyAlias "xxx"
keyPassword "xxx"
}
}
使用命令:
.\gradlew -Pmarket=markets.txt clean apkRelease
来打包即可
原因:mavenCentral仓库没有gradle:2.2.0
解决:
buildscript {
repositories {
jcenter() //增加jcenter仓库
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
// add packer-ng
classpath 'com.mcxiaoke.gradle:packer-ng:1.0.4'
}
}
apply plugin: 'com.android.application'
apply plugin: 'packer' //一定要加这一行
android {
...
}
KEYSTORE_FILE= my.keystore
KEYSTORE_PASSWORD= xxx
KEY_ALIAS= xxx
KEY_PASSWORD= xxx
KEYSTORE_FILE= D:/my.keystore
android {
...
}
def getSignInfo() {
def com.android.build.gradle.internal.dsl.SigningConfig signingConfig = new com.android.build.gradle.internal.dsl.SigningConfig("signInfo")
File propFile = file("signing.properties");
if (propFile.exists()) {
def Properties props = new Properties()
props.load(new FileInputStream(propFile))
signingConfig.storeFile = file(props['KEYSTORE_FILE'])
signingConfig.storePassword = props['KEYSTORE_PASSWORD']
signingConfig.keyAlias = props['KEY_ALIAS']
signingConfig.keyPassword = props['KEY_PASSWORD']
println('signConfig is exits')
} else {
println('sign config is null')
signingConfig = null
}
signingConfig.v2SigningEnabled=false
return signingConfig;
}
buildTypes {
release {
...
signingConfig signingConfigs.release
...
}
}
signingConfig signingConfigs.release
signingConfig getSignInfo()