title: BuildConfig Constants for buildType per each productFlavors in Gradle file
body: <p>I have two applications have single base code in <strong>main folder</strong>  and each application have three types of buildTypes call <strong>debug</strong>, <strong>preview</strong> and <strong>release</strong>. So I created </p>
  
  <p><strong><em>two</strong> productFlavors</em> i.e App1, App2</p>
  
  <p><strong><em>three</strong> buildTypes</em> i.e debu,preview and release</p>
  
  <p>but each application has <strong><em>different URLs for different build types</em></strong> </p>
  
  <p>my project structure is like </p>
  
  <p><a href="https://i.stack.imgur.com/M820f.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M820f.jpg" alt="enter image description here"></a></p>
  
  <p>what I tried </p>
  
  <p><strong>build.gradle file</strong> </p>
  
  <pre><code>    apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 25
      buildToolsVersion "25.0.1"
      defaultConfig {
          applicationId "ksp.com.buidflavourspoc"
          minSdkVersion 21
          targetSdkVersion 25
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
  
      signingConfigs {
          debug {
  //
          }
          preview {
  //
          }
          release {
              keyAlias 'test'
              keyPassword 'test'
              storePassword 'test'
          }
      }
      buildTypes {
          def BOOLEAN = "boolean";
          def TRUE = "true";
          def FALSE = "false";
          def IS_LOG = "IS_LOG";
          debug {
              buildConfigField BOOLEAN, IS_LOG, FALSE
          }
          preview {
              buildConfigField BOOLEAN, IS_LOG, FALSE
          }
          release {
              buildConfigField BOOLEAN, IS_LOG, TRUE
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  
      productFlavors {
          app1 {
              applicationId ".com.android.app1"
              buildConfigField 'String', 'HOST', '"http://app1curl.com"'
          }
          app2 {
              applicationId ".com.android.app2"
              buildConfigField 'String', 'HOST', '"app2url.com"'
          }
  
      }
  }
  
  dependencies {
      compile fileTree(include: ['*.jar'], dir: 'libs')
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
      compile 'com.android.support:appcompat-v7:25.1.0'
      testCompile 'junit:junit:4.12'
  }
  </code></pre>
  
  <p>With this, I can get URL's based on product flavor (<code>like BuildConfig.HOST</code>) but I can't get <strong>APP1debug HOST</strong> separate if I select<strong>APP1debug</strong> </p>
  
  <p><strong>How can I relates both ??</strong> i.e I want to get debug URL for APP1 from Gradle if I select <strong>APP1debug</strong> </p>
  
  <p>like </p>
  
  <p><a href="https://stackoverflow.com/q/27405301/5955593"><img src="https://i.stack.imgur.com/cu76d.jpg" alt="enter image description here"></a></p>
  
  <p>I have gone through <a href="https://stackoverflow.com/q/27405301/5955593">BuildConfig prop for each buildType</a> but did not find the solution. </p>
  
  <p>Welcome any suggestions from Android community. </p>
  
  <p>I am thinking like </p>
  
  <pre><code> productFlavors {
              app1 {
                  applicationId ".com.android.app1"
                 if(buildTypes.DEBUG){
                  buildConfigField 'String', 'HOST', '"http://app1curldebug.com"'
  }else{
   buildConfigField 'String', 'HOST', '"http://app1curlpreview.com"'
  }
              }
              app2 {
                  applicationId ".com.android.app2"
                  if(buildTypes.DEBUG){
                  buildConfigField 'String', 'HOST', '"app2urldebug.com"'
  }else{
   buildConfigField 'String', 'HOST', '"app2urlpreview.com"'
  }
              }
  </code></pre>
  
  <p>But don't know how to use if conditions in build.gradle file !</p>