在 Gradle 产品风味上调试签名配置 [英] Debug Signing Config on Gradle Product Flavors

查看:24
本文介绍了在 Gradle 产品风味上调试签名配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,其中有几种特定于设备的产品风味,并且每种风味都需要使用不同的配置进行签名:

I've got a project where I have several device-specific product flavors, and each flavor needs to be signed with a different config:

productFlavors {
    nexus7 {
        signingConfig signingConfigs.nexus7
    }
    nexus4 {
        signingConfig signingConfigs.nexus4
   }
}

这在构建发布"变体时非常有效.但是,当使用调试"变体时(例如,当我构建 Nexus4Debug 时),Gradle 使用默认的 android 调试键.就我而言,我高度依赖于以正确方式签署这些构建,如果使用默认调试密钥签署,我的应用程序相对无用.任何人都知道是否有办法为每个变体指定签名配置?

This works great when building a 'release' variant. However, when using a 'debug' variant (e.g. when I build Nexus4Debug), Gradle is using the default android debug key. In my case, I'm highly dependent on these builds being signed the right way, and my application is relatively useless if signed with the default debug key. Anyone know if there's a way to specify the signing config for each variant?

我知道我可以按构建类型来做,例如:

I know I can do it per build type, a la:

buildTypes {
    debug {
        signingConfig signingConfigs.nexus4
    }
}

但这限制了我总是使用相同的签名配置来调试两种风格的版本.

but this limits me to always using the same signing config for debug builds of both flavors.

PS - 理解这是这里的一个边缘用例.这是针对一个企业项目,我们在多个不同的 Nexus 设备上测试自定义 ROM 和系统签名应用.

PS - Understand this is a little bit of an edge use case here. This is for an enterprise project where we're testing custom ROMs and system-signed apps on a number of different Nexus devices.

推荐答案

尝试将其添加到您的 build.gradle.它将指定在构建 debug 构建类型时为每个 flavor 使用哪个 signingConfig:

Try adding this to your build.gradle. It will specify which signingConfig to use for each flavor when building the debug build type:

buildTypes {
    debug {
        productFlavors.nexus4.signingConfig signingConfigs.nexus4
        productFlavors.nexus7.signingConfig signingConfigs.nexus7
    }
}

这篇关于在 Gradle 产品风味上调试签名配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆