title: Renaming apk with gradle -> getting same apk twice
body: <p>I have an app with different flavors - each flavor has two buildTypes.</p>
  
  <p>After renaming some lines in my manifest i also rename the apk. Everything works fine - I just wonder why I get the same apks twice? Once not renamed and once renamed...</p>
  
  <p>Short example of the same app with different Names:</p>
  
  <ul>
  <li>"myApp-flavor-buildType.apk" (not renamed)</li>
  <li>"myApp-appName-buildType-version.apk" (renamed apk)</li>
  </ul>
  
  <p>Here is the code of my build.gradle file:</p>
  
  <pre><code>// *** OVERRIDE data in MANIFEST ***
  android.applicationVariants.each { variant -&gt;
      variant.processManifest.doLast {
          overrideDataInManifest(variant)
      }
  }
  
  def overrideMapsKey(buildVariant){
      def appName = getAppName(buildVariant)
  
      // override line ... this is not necessary to this question
  
      renameAPK(buildVariant, appName)
  }
  
  // *** RENAME APK ***
  def renameAPK(buildVariant, appName){
      def apk = buildVariant.packageApplication.outputFile;
      def newName = "";
  
      // get data for apk renaming
      def versionName = android.defaultConfig.versionName 
      def versionNameSuffix = buildVariant.buildType.versionNameSuffix
      if(versionNameSuffix.toString().equals("null"))
          versionNameSuffix = ""
      def buildTypeOfApp= buildVariant.buildType.name 
  
      if (buildVariant.zipAlign) {
          newName = "etscanner-" + appName + "-" + buildTypeOfApp.toUpperCase() + "-v" + versionName + versionNameSuffix + ".apk"
      }else{
          newName = "etscanner-" + appName + "-" + buildTypeOfApp.toUpperCase() + "-v" + versionName + versionNameSuffix + "-ALIGNED" + ".apk"
      }
      buildVariant.packageApplication.outputFile = new File(apk.parentFile, newName);
  }
  </code></pre>
  
  <p>Just want to know whats going on and if the same task is possible without getting two apks. </p>