【发布时间】:2015-09-03 02:28:44
【问题描述】:
我的 Android 应用程序有多种版本,我希望除一个之外的所有应用程序都使用相同的密钥。有一个需要使用不同的密钥。
如何仅针对 1 种风格的应用覆盖 signingConfig(但在相同的构建类型中,例如“发布”)?
- 我希望所有构建默认使用主发布配置。
- 我只想覆盖一种风味
- 我希望能够使用单个
gradlew assembleRelease命令运行所有发布版本
最后一点很重要,因为我目前有超过 120 种不同的口味,而且还在不断增长。为了单独定制每一种口味,需要做很多额外的工作。
我尝试过的相关帖子:
Producing multiple builds signed with different keys from single build type
- 这需要为每种风味进行配置
- 它似乎并没有使用我的自定义
signingConfig反正
Signing product flavors with gradle
- 已接受的解决方案不起作用(对我而言)
- 根据a comment,这可以通过将
buildTypes放在productFlavors中来实现,但我不明白该怎么做。
Debug Signing Config on Gradle Product Flavors
- 如博文所述:Building Multiple Editions of an Android App with Gradle
-
它不工作实际上它完美地工作 - 但它不能很好地适应 119 种口味
总的来说,每个解决方案似乎仍然使用默认的发布配置,而不是我的自定义配置。
build.gradle 的重要部分如下所示:
signingConfigs {
releaseConfig {
storeFile file('key')
storePassword "pass"
keyAlias "alias"
keyPassword "pass"
}
custom {
storeFile file('custom_key')
storePassword "pass"
keyAlias "alias"
keyPassword "pass"
}
}
productFlavors {
apple {
applicationId "demo.apple"
}
banana {
applicationId "demo.banana"
}
// def customConfig = signingConfigs.custom
custom {
applicationId "custom.signed.app"
// signingConfig customConfig
}
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
signingConfig signingConfigs.releaseConfig
// productFlavors.custom.signingConfig signingConfigs.custom
}
}
【问题讨论】:
-
也许就像在文档中找到解释这一点的位置一样简单 - 我没有发现 Gradle 的文档特别好。
-
感谢您的精彩问答!我看到你现在维护了大约 120 种口味,而且构建时间很长。我在创建一个必须多次重新命名的同时标签应用程序的同一条船上。我才刚开始。我必须使用不同的密钥来签署每种风格,但还有其他 UI 和配置更改。你对如何维护如此庞大的项目架构/配置有什么建议吗?如果你现在可以从头开始,你应该注意什么,或者你会做些什么不同的事情?如果您有时间分享,这将是一篇博文的好主题;)。提前致谢。
标签: android gradle android-gradle-plugin code-signing