title: android-gradle set versionNameOverride does not set versionName in BuildConfig.java
body: <p>We have a <code>release</code> and <code>debug</code> buildType and want to set the <code>versionCode</code> and <code>versionName</code> to a constant value for <code>debug</code> as otherwise, every build repackages the apk, even without code changes.</p>
  
  <p>So we set a fixed default <code>versionCode</code> and later override it for a specific buildType:</p>
  
  <pre><code>android {
      compileSdkVersion 28
      defaultConfig {
          applicationId "com.example.gradletest"
          minSdkVersion 28
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      }
  
      applicationVariants.all { variant -&gt;
          if (!variant.buildType.isDebuggable()) {
              variant.outputs.each { output -&gt;
                  output.versionCodeOverride = getAppVersionCode()
                  output.versionNameOverride = getAppVersionName()
              }
          }
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
          debug {
              signingConfig signingConfigs.debug
              debuggable true
          }
      }
  }
  </code></pre>
  
  <p>while this works for the apk, unfortunately the generated <code>class BuildConfig</code> always has the default <code>1/"1.0"</code> value. We read and show the <code>versionNumber</code> from within the app as this <a href="https://stackoverflow.com/a/21119027/1469472">popular answer</a> suggests.</p>
  
  <p>Apparently <code>BuildConfig.java</code> is generated at configuration, not at project build, so it can't know the chosen variant. How to handle this?</p>
  
  <p>Our <code>getAppVersionCode()</code> is containing a timestamp, so every versionCode is different. I tried flipping the statements, so that the debug builds would show a different versionCode and versionName everytime, which would be fine for us.</p>
  
  <pre><code>android {
      defaultConfig {
          versionCode getAppVersionName()
          versionName getAppVersionCode()
      }
  
      applicationVariants.all { variant -&gt;
          if (variant.buildType.isDebuggable()) {
              variant.outputs.each { output -&gt;
                  output.versionCodeOverride = 1
                  output.versionNameOverride = "1.0"                
              }
          }
      }
  }
  </code></pre>
  
  <p>The reason why we have a fixed debug <code>versionCode</code> in the first place is that we don't want to rebuild all submodules for every code change. With the second variant, even though we set a fixed <code>versionNumber</code> for the debug build through <code>output.versionCodeOverride = 1</code> all submodules are rebuild by Android Studio. Before Android Studio 3.0 this worked but doesn't anymore. Please advise.</p>