title: How to customize the APK file name for product flavors?
body: <p>I am customizing the <strong>name of the APK</strong> file of my Android application within the <code>build.gradle</code> script as follows:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>android {
      defaultConfig {
          project.ext.set("archivesBaseName", "MyApplication");
      }
  }
  </code></pre>
  
  <p>Now that I am using product flavors:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>android {
      productFlavors {
          green {
              applicationId "com.example.myapplication.green"
          }
  
          blue {
              applicationId "com.example.myapplication.blue"
          }
      }
  }
  </code></pre>
  
  <p>Is there a way to customize the name of <strong>each APK</strong>? I experimented with <code>archiveBaseName</code> and <code>baseName</code> without success. In the end I want to come up with the following files:</p>
  
  <pre><code>build/outputs/apk/Blue-debug-1.2.1.apk
  build/outputs/apk/Blue-debug-unaligned.apk
  build/outputs/apk/Blue-release-1.2.1.apk
  build/outputs/apk/Blue-release-unaligned.apk
  build/outputs/apk/Green-debug-1.2.1.apk
  build/outputs/apk/Green-debug-unaligned.apk
  build/outputs/apk/Green-release-1.2.1.apk
  build/outputs/apk/Green-release-unaligned.apk
  </code></pre>