生产多个构建从单一的构建类型不同的密钥签名 [英] Producing multiple builds signed with different keys from single build type

查看:170
本文介绍了生产多个构建从单一的构建类型不同的密钥签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的摇篮构建我的Andr​​oid项目,使用默认的调试和发布生成类型。我想生产基于发布版本的类型,用不同的密钥签署了两份的APK。人会进行检测,而另一个将是实际播放存储。另外,我想可以同时生成符号和无符号版本。

I am using Gradle to build my Android project, with the default debug and release build types. I want to produce two APKs based on the release build type, signed with different keys. One would be for testing, and the other would be for the actual Play store. Alternatively, I want to generate both a signed and unsigned build.

我知道我可以修改发布版本类型签订配置与以下内容:

I know I can modify the signing config of the release build type with the following:

android {
    signingConfigs {
        myConfig1 {
            ...
        }

        myConfig2 {
            ...
        }
    }

    buildTypes {
        release {
            signingConfig ...
        }
    }
}

我怎么能指定两个签约CONFIGS,和/或有生产的gradle符号和无符号的建立?

How can I specify two signing configs, and/or have gradle produce both signed and unsigned builds?

有一件事情我已经尝试正在一个新的版本类型和调用initWith(buildTypes.release)。然后,我指定了不同的配置签署那里。问题是,它将重建每一个构建类型整个应用程序,这是我想避免,如果可能的话。

One thing I have tried is making a new build type and calling initWith(buildTypes.release). I then specified a different signing config there. The problem is that it rebuilds the entire app for every build type, which I want to avoid, if possible.

推荐答案

只要创建两个不同发布版本的类型,每一个签约的配置。

Just create two different release build types, one for each signing config.

android {
    signingConfigs {
        myConfig1 {
            ...
        }

        myConfig2 {
            ...
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.myConfig1
        }
        release2 {
            signingConfig signingConfigs.myConfig2
        }
    }
}

这篇关于生产多个构建从单一的构建类型不同的密钥签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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