title: Android Build Variant Signing Config
body: <p>I have the following in my android app module build.gradle file.</p>
  
  <pre><code>android {
  
      defaultConfig {
          ...
      }
  
      signingConfigs {
          if (System.getEnv()['CIRCLE-CI']) { /* CI System */
              localMachine { /* CI System KeyStore file and properties. */
                  ...
                  keyAlias = "ABC"
              }
              playStore { /* CI System KeyStore file and properties. */
                  ...
                  keyAlias = "ABC"
              }
          } else { /* Local machine, not CI System. */
              localMachine { /* debug.keystore local file and properties. */
                  ...
                  keyAlias = "androiddebugkey"
              }
              playStore { /* debug.keystore local file and properties. */
                  ...
                  keyAlias = "androiddebugkey"
              }
          }
      }
  
      productFlavors {
          productOne {
              ...
          }
          productTwo {
              ...
          }
      }
  
      buildTypes {
          debug {
              ...
          }
          release {
              ...
          }
      }
  }
  
  /** This is where the problem is **/
  android.applicationVariants.all { variant -&gt; 
          if (variant.mergedFlavor.name == "productOne") {
              if (variant.buildType.name == "debug") {
                  variant.signingConfig android.signingConfigs.localMachine
              } else if (variant.buildType.name == "release") {
                  variant.signingConfig android.signingConfigs.playStore
              }
          } else if (variant.mergedFlavor.name == "productTwo") {
              if (variant.buildType.name == "debug") {
                  variant.signingConfig android.signingConfigs.localMachine
              } else if (variant.buildType.name == "release") {
                  variant.signingConfig null
              }
          }
      }
  }
  </code></pre>
  
  <p>Expected output is as follows.</p>
  
  <pre><code>productOneDebug -&gt; Sign with signingConfigs.localMachine
  productTwoDebug -&gt; Sign with signingConfigs.localMachine
  productOneRelease -&gt; Sign with signingConfigs.playStore
  productTwoRelease -&gt; Unsigned.
  </code></pre>
  
  <p>Actual output is as follows.</p>
  
  <pre><code>productOneDebug -&gt; Signed with signingConfigs.localMachine
  productTwoDebug -&gt; Signed with signingConfigs.localMachine
  productOneRelease -&gt; Unsigned.
  productTwoRelease -&gt; Unsigned.
  </code></pre>
  
  <p>Why are Release apks always unsigned?
  The intention is to only have ProductTwo Release apk unsigned, but ProductOne Release apk should be signed based on the given configuration.</p>