Signing product flavors with gradle

后端 未结 3 1491
梦毁少年i
梦毁少年i 2020-11-29 22:56

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

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 23:26

    The gradle plugin for android only supports signing per build type, not per flavor. The reason for this is that any given variant (build type + flavors) can only be signed by one key, but can be a combination of several flavor groups. For example your flavor groups could be cpu (x86/arm) and version (free/paid), that's four different variants right there.

    The solution you're looking for is to create separate build types for your different release versions. For example, your build types might be debug, release, release-beta, like this:

    ...
    
    android {
    
        ...
    
        buildTypes {
            debug {
                signingConfig signingConfigs.debug
            }
    
            release {
                signingConfig signingConfigs.release
            }
    
            release-beta {
                initWith release
                signingConfig signingConfigs.release-beta
            }
        }
    }
    

    The initWith above just tells gradle that release-beta should be a copy of the release build type, only signed with a different key.

提交回复
热议问题