title: Android Gradle build file with Time Stamp running yesterdays version
body: <p>Below I have my build file for Gradle. 
  Issue. It runs yesterday's APK instead of today's.
  Root cause. I dynamically put the date in the apks name -- for debug builds.</p>
  
  <p>When I run the app it sees the old APK and sees it matches what Gradle is expecting, as Gradle has not refreshed and noticed the date change.</p>
  
  <p>I need to force gradle to refresh every run.</p>
  
  <pre><code>buildTypes {
     debug {
          debuggable true
          minifyEnabled false
          proguardFiles 'proguard-rules.pro'
          applicationVariants.all { variant -&gt;
              variant.outputs.each { output -&gt;
                  def formattedDate = new Date().format('yyyyMMdd')
                  def newName = output.outputFile.name
                  newName = newName.replace("app-", "myappname-") //"MyAppName" -&gt; I set my app variables in the root project
                  newName = newName.replace("-release", "-" + versionName + "-" + formattedDate + "-r")
                  newName = newName.replace("-debug", "-" + versionName + "-" + formattedDate + "-d")
                  output.outputFile = new File(output.outputFile.parent, newName)
              }
          }
      }
   }
  </code></pre>