例如,我有一个gradle构建如下:
signingConfigs {
configFlavor1 {
keyAlias 'alias1'
keyPassword 'password1'
storeFile file('location1')
storePassword 'password1'
v1SigningEnabled true
v2SigningEnabled true
}
configFlavor2 {
keyAlias 'alias2'
keyPassword 'password2'
storeFile file('location2')
storePassword 'password2'
v1SigningEnabled true
v2SigningEnabled true
}
configFlavor3 {
keyAlias 'alias3'
keyPassword 'password3'
storeFile file('location3')
storePassword 'password3'
v1SigningEnabled true
v2SigningEnabled true
}
}
flavorDimensions "dimen1", "dimen2"
productFlavors {
flavor1 {
dimension "dimen1"
}
flavor2 {
dimension "dimen1"
}
testing {
dimension "dimen2"
}
dev {
dimension "dimen2"
}
prod {
dimension "dimen2"
}
}
现在我想使用特定于此风味维度组合的签名配置..例如..我想签名:
flavor1Prod with configFlavor1
flavor2Prod with configFlavor2
flavor1Dev with configFlavor3
etc...
我尝试过这样的事情,
applicationVariants.all { variant ->
def mergedFlavor = variant.mergedFlavor
switch (variant.flavorName) {
case "flavor1Prod":
mergedFlavor.signingConfig = signingConfigs.configFlavor1
break
case "flavor2Prod":
mergedFlavor.signingConfig = signingConfigs.configFlavor2
break
... soo on...
}
}
但是每当我尝试运行时,它仍然会尝试生成一个未签名的apk。
有人可以帮助我吗?