多渠道打包使用不同包名和签名配置
在app工程目录下的build.gradle
文件进行配置:
- 1
配置多渠道
def IS_RELEASE = getGradle().getStartParameter().getTaskRequests().toString().contains("Release")
flavorDimensions "default"
productFlavors {
local/*渠道名称*/ {
if (IS_RELEASE) {// 区分生产包和debug包
applicationId "com.xxxx.app"
} else {
applicationId "com.xxxx.app.debug"
}
// sdk需要的一些清单配置
manifestPlaceholders = [key: value,
JPUSH_PKGNAME: applicationId,
JPUSH_CHANNEL: "developer-default"]
}
googleplay {
if (IS_RELEASE) {
applicationId "com.xxxx.googleplay.app"
} else {
applicationId "com.xxxx.googleplay.app.debug"
}
manifestPlaceholders = [target_app_store: "googleplay",
JPUSH_PKGNAME: applicationId,
JPUSH_CHANNEL: "developer-default"]
}
}
// 签名
signingConfigs {
local {
storeFile file("./keystore/local-keystore.jks")
storePassword "xxxxxx"
keyAlias "local"
keyPassword "xxxxx"
}
google {
storeFile file("./keystore/googleplay.jks")
storePassword "xxxxx"
keyAlias "googleplay"
keyPassword "xxxxxx"
}
}
buildTypes {
debug {
// 签名配置,根据渠道包配置不同的签名
productFlavors.local.signingConfig signingConfigs.local
productFlavors.googleplay.signingConfig signingConfigs.local
...
}
release {
// 签名配置,根据渠道包配置不同的签名
productFlavors.local.signingConfig signingConfigs.local
productFlavors.googleplay.signingConfig signingConfigs.local
...
}
}
解释: