title: Get product flavor or build variant in an android app
body: <p>I have an android app with a number of different product flavors configured in my build.gradle file eg</p>
  
  <pre><code>productFlavors {
      someFlavor {}
      anotherFlavor {}
  }
  </code></pre>
  
  <p>In my application code, I want to be able to get hold of the name of the currently compiled flavor (or build variant). One solution is this:</p>
  
  <pre><code>productFlavors {
      someFlavor {
          buildConfig "public static final String PRODUCT_FLAVOR = \"someFlavor\";"
      }
      anotherFlavor {
          buildConfig "public static final String PRODUCT_FLAVOR = \"anotherFlavor\";"
      }
  }
  </code></pre>
  
  <p>And then in my android app call <code>BuildConfig.PRODUCT_FLAVOR</code>.</p>
  
  <p>Is there some way I can get gradle to do this automatically? Or is there some other API in android I can use to get the product flavor name?</p>