Debug Signing Config on Gradle Product Flavors

前端 未结 3 758
礼貌的吻别
礼貌的吻别 2020-12-08 08:08

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 {
    n         


        
相关标签:
3条回答
  • 2020-12-08 08:33

    Works on 2.2.1

    buildTypes {
        release {
        }
        debug {
            signingConfig android.buildTypes.release.signingConfig
        }
    }
    
    0 讨论(0)
  • 2020-12-08 08:37

    I got another solution after android plugin build. 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
        }
    }
    

    As build type "release" will use flavor signing config (as there is no specification), after debug init with release build, it will also has the same signing config.

    Build type "debug" needs to be init with "release" as if signing config is not provided, it will use Android default debug signing key.

    Update

    The problem is that android.buildTypes.debug.signingConfig has a default value while release does not.

    The solution may be breakage in the future.

    Anyway, still work with android plugin build 2.3.2

    0 讨论(0)
  • 2020-12-08 08:46

    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
        }
    }
    
    0 讨论(0)
提交回复
热议问题