我tyring迁移我的项目摇篮。我的一个项目中有多个产品的风味和他们每个人都有用不同的signingConfig在其发布版本签名。所以这是我试过到目前为止:
I am tyring to migrate my projects to gradle. One of my projects has multiple product flavors and each one of them has to be signed with a different signingConfig in its release version. So this is what I tried so far:
buildscript {
...
}
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion '17'
signingConfigs {
flavor1 {
storeFile file("keystore")
storePassword "secret"
keyAlias "aliasForFlavor1"
keyPassword "secretFlavor1"
}
flavor2 {
storeFile file("keystore")
storePassword "secret"
keyAlias "aliasForFlavor2"
keyPassword "secretFlavor2"
}
}
productFlavors {
flavor1 {
signingConfig signingConfigs.flavor1
}
flavor1 {
signingConfig signingConfigs.flavor2
}
}
}
dependencies {
...
}
当我运行摇篮构建
我收到了 groovy.lang.MissingFieldException
和以下错误消息:
When I run gradle build
I get a groovy.lang.MissingFieldException
and the following error message:
No such field: signingConfigs for class: com.android.build.gradle.internal.dsl.GroupableProductFlavorFactory
所以我假定productFlavors。*的摇篮脚本的一部分是不正确的地方放code签约配置。
So I assume the productFlavors.* part of the gradle script is not the right place to put code signing configurations.
推荐答案
按照用户指南,支持signingConfigs的味道。
Per the user guide, signingConfigs for flavors are supported.
这里的问题,是因为有所述signingConfigs对象的范围。我刚分配到了 productFlavors
块中的变量,但 flavor1
的味道外块来解决这个问题:
The problem here has to do with the scope of the signingConfigs object. I just assigned it to a variable inside the productFlavors
block, but outside the flavor1
flavor block to fix the issue:
productFlavors {
def flavor1SigningVariable = signingConfigs.flavor1
flavor1 {
...
signingConfig flavor1SigningVariable
...
}
相关推荐
最新文章