MJM*_*o06 18 android build code-signing gradle
我有一个项目,我有几个特定于设备的产品口味,每个口味需要用不同的配置签名:
productFlavors {
nexus7 {
signingConfig signingConfigs.nexus7
}
nexus4 {
signingConfig signingConfigs.nexus4
}
}
Run Code Online (Sandbox Code Playgroud)
这在构建"发布"变体时非常有用.但是,当使用'debug'变体时(例如,当我构建Nexus4Debug时),Gradle使用默认的android调试密钥.在我的情况下,我高度依赖这些构建以正确的方式签名,如果使用默认调试密钥签名,我的应用程序相对无用.任何人都知道是否有办法为每个变体指定签名配置?
我知道我可以按照构建类型来做,la:
buildTypes {
debug {
signingConfig signingConfigs.nexus4
}
}
Run Code Online (Sandbox Code Playgroud)
但这限制了我总是使用相同的签名配置来调试两种风格的版本.
PS - 了解这是一个有点边缘用例的地方.这是一个企业项目,我们在许多不同的Nexus设备上测试自定义ROM和系统签名的应用程序.
小智 9
尝试将此添加到build.gradle.它将在构建构建类型时指定signingConfig
每个使用的内容:flavor
debug
buildTypes {
debug {
productFlavors.nexus4.signingConfig signingConfigs.nexus4
productFlavors.nexus7.signingConfig signingConfigs.nexus7
}
}
Run Code Online (Sandbox Code Playgroud)
android插件构建后,我得到了另一个解决方案.1.1.3
productFlavors {
nexus7 {
signingConfig signingConfigs.nexus7
}
nexus4 {
signingConfig signingConfigs.nexus4
}
}
buildTypes {
release {
debuggable false
zipAlignEnabled true
}
debug {
initWith release
debuggable true
zipAlignEnabled false
}
}
Run Code Online (Sandbox Code Playgroud)
由于构建类型"release"将使用flavor签名配置(因为没有规范),在使用release build的debug init之后,它也将具有相同的签名配置.
构建类型"debug"需要使用"release"进行初始化,就像没有提供签名配置一样,它将使用Android默认调试签名密钥.
更新
问题是android.buildTypes.debug.signingConfig有一个默认值,而release则没有.
解决方案将来可能会破裂.
无论如何,仍然使用android插件构建2.3.2
小智 5
适用于 2.2.1
buildTypes {
release {
}
debug {
signingConfig android.buildTypes.release.signingConfig
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6673 次 |
最近记录: |