title: Keep product flavors from effecting build times in Android Studio
body: <p>My app currently has 5 different product flavors.  The reasons aren't really that important are in my control, but essentially we need this many product flavors to target different testing servers that have different testing data.</p>
  
  <pre><code>    prod {
          applicationId "com.us.android"
      }
  
      stage {
          applicationId "com.us.android.stage"
      }
  
      qa {
          applicationId "com.us.android.qa"
      }
  
      dev {
          applicationId "com.us.android.dev"
      }
  
      legacy {
          applicationId "com.us.android.legacy"
      }
  </code></pre>
  
  <p>The issue I'm running into is whenever I create a new build all of the product flavors are built.  So for my project to build it takes about 50 seconds, if I were to comment out all, but the build I care about that time goes down to about 10 seconds.  That said commenting them out is great if it were just me, but if I accidentally commit the commented out version, that's going to cause more problems when we try to build elsewhere.</p>
  
  <p>My question is, is there is any clean way I can make it so that in the local development only the build I need is built, but I can still build the other branches as needed?</p>
  
  <p>We are using Jenkins which, I figure seems like it could help us get these builds where we don't need to worry about them, but I'm not sure how.</p>
  
  <p><strong>Edit:</strong> Here are some logs, because that might help.</p>
  
  <p>This is when we have all the product flavors but, the build variant set to stageDebug:</p>
  
  <pre><code>    Executing tasks: [:us:assembleStageDebug]
  
  Parallel execution with configuration on demand is an incubating feature.
          :api:compileJava
  :datePickerLibrary:compileLint
  :us:preBuild UP-TO-DATE
  :us:preStageDebugBuild UP-TO-DATE
  :datePickerLibrary:copyReleaseLint UP-TO-DATE
  :us:checkStageDebugManifest
  :datePickerLibrary:preBuild UP-TO-DATE
  :datePickerLibrary:preReleaseBuild UP-TO-DATE
  :datePickerLibrary:checkReleaseManifest
  :us:preDevDebugBuild UP-TO-DATE
  :datePickerLibrary:preDebugAndroidTestBuild
  :us:preDevReleaseBuild UP-TO-DATE
  :datePickerLibrary:preDebugAndroidTestBuild UP-TO-DATE
  :datePickerLibrary:preDebugBuild UP-TO-DATE
  :us:preProdDebugBuild UP-TO-DATE
  :datePickerLibrary:preDebugUnitTestBuild UP-TO-DATE
  :us:preProdReleaseBuild UP-TO-DATE
  :datePickerLibrary:preReleaseUnitTestBuild UP-TO-DATE
  :us:preQaDebugBuild UP-TO-DATE
  :datePickerLibrary:prepareComAndroidSupportSupportV132100Library
  :us:preQaReleaseBuild UP-TO-DATE
  :us:preStageReleaseBuild UP-TO-DATE
  :us:prelegacyDebugBuild UP-TO-DATE
  :us:prelegacyReleaseBuild UP-TO-DATE
  :datePickerLibrary:prepareComAndroidSupportSupportV132100Library UP-TO-DATE
  :datePickerLibrary:prepareComAndroidSupportSupportV42100Library
  :us:generateStageDebugBuildConfig UP-TO-DATE
  :datePickerLibrary:prepareReleaseDependencies UP-TO-DATE
  :us:generateStageDebugResValues
  :datePickerLibrary:compileReleaseAidl UP-TO-DATE
  :api:processResources UP-TO-DATE
  :datePickerLibrary:prepareComAndroidSupportSupportV42100Library UP-TO-DATE
  :us:processStageDebugGoogleServices
  File google-services.json is missing from module root folder. The Google Quickstart Plugin cannot function without it.
          :api:classes
  :us:generateStageDebugAssets UP-TO-DATE
  :api:classes UP-TO-DATE
  :api:compileJava UP-TO-DATE
  :api:jar
  :us:processStageDebugJavaRes UP-TO-DATE
  :datePickerLibrary:compileReleaseRenderscript
  :us:compileStageDebugNdk UP-TO-DATE
  :us:newRelicInstrumentTask UP-TO-DATE
  :datePickerLibrary:generateReleaseBuildConfig UP-TO-DATE
  :datePickerLibrary:generateReleaseAssets UP-TO-DATE
  :datePickerLibrary:mergeReleaseAssets UP-TO-DATE
  :datePickerLibrary:compileReleaseRenderscript UP-TO-DATE
  [newrelic.info] Detected cached instrumentation.
  :datePickerLibrary:generateReleaseResValues UP-TO-DATE
  :datePickerLibrary:generateReleaseResources UP-TO-DATE
  :datePickerLibrary:mergeReleaseResources UP-TO-DATE
  :datePickerLibrary:processReleaseManifest UP-TO-DATE
  :datePickerLibrary:processReleaseResources UP-TO-DATE
  :datePickerLibrary:generateReleaseSources UP-TO-DATE
  :datePickerLibrary:processReleaseJavaRes UP-TO-DATE
  :datePickerLibrary:compileReleaseJavaWithJavac UP-TO-DATE
  :datePickerLibrary:extractReleaseAnnotations UP-TO-DATE
  :datePickerLibrary:mergeReleaseProguardFiles UP-TO-DATE
  :datePickerLibrary:packageReleaseJar UP-TO-DATE
  :datePickerLibrary:compileReleaseNdk UP-TO-DATE
  :datePickerLibrary:packageReleaseJniLibs UP-TO-DATE
  :datePickerLibrary:packageReleaseLocalJar UP-TO-DATE
  :datePickerLibrary:packageReleaseRenderscript UP-TO-DATE
  :datePickerLibrary:packageReleaseResources
  :api:jar UP-TO-DATE
  :us:validateDebugSigning
  :datePickerLibrary:bundleRelease
  :us:validateDebugSigning UP-TO-DATE
  :us:prepareAndroidClientDatePickerLibraryUnspecifiedLibrary UP-TO-DATE
  :us:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
  :us:prepareComAndroidSupportCardviewV72221Library UP-TO-DATE
  :us:prepareComAndroidSupportDesign2221Library UP-TO-DATE
  :us:prepareComAndroidSupportMultidex101Library UP-TO-DATE
  :us:prepareComAndroidSupportRecyclerviewV72221Library UP-TO-DATE
  :us:prepareComAndroidSupportSupportV132221Library UP-TO-DATE
  :us:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
  :us:prepareComFacebookAndroidFacebookAndroidSdk3230Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
  :us:prepareComInstabugLibraryInstabugcore17Library UP-TO-DATE
  :us:prepareComInstabugLibraryInstabugsupport17Library UP-TO-DATE
  :us:prepareComMixpanelAndroidMixpanelAndroid462Library UP-TO-DATE
  :us:prepareComRengwuxianMaterialedittextLibrary214Library UP-TO-DATE
  :us:prepareComRoomoramaCaldroid220Library UP-TO-DATE
  :us:prepareComZendeskSdk1322Library UP-TO-DATE
  :us:prepareUkCoChrisjenxCalligraphy201Library UP-TO-DATE
  :us:prepareStageDebugDependencies
  :us:compileStageDebugAidl UP-TO-DATE
  :us:compileStageDebugRenderscript UP-TO-DATE
  :us:generateStageDebugResources
  :us:mergeStageDebugResources UP-TO-DATE
  :us:jrebelPinStageDebugResids UP-TO-DATE
  :us:mergeStageDebugAssets UP-TO-DATE
  :us:processStageDebugManifest UP-TO-DATE
  :us:processStageDebugResources UP-TO-DATE
  :us:generateStageDebugSources UP-TO-DATE
  :us:compileStageDebugJavaWithJavac UP-TO-DATE
  :us:compileStageDebugSources UP-TO-DATE
  :us:generateStageDebugJrebelLayout
  :us:preDexStageDebug UP-TO-DATE
  :us:dexStageDebug UP-TO-DATE
  :us:newRelicDeinstrumentTask
  [newrelic.info] Deinstrumenting...
          :us:jrebelPostProcessStageDebugResids UP-TO-DATE
  :us:packageStageDebug UP-TO-DATE
  :us:zipalignStageDebug UP-TO-DATE
  :us:assembleStageDebug
  
  BUILD SUCCESSFUL
  
  Total time: 34.308 secs
  </code></pre>
  
  <p>This is when we only have the desired stage product flavor:</p>
  
  <pre><code>Executing tasks: [:urbansitter:assembleStageDebug]
  Parallel execution with configuration on demand is an incubating feature.
          :api:compileJava
  :datePickerLibrary:compileLint
  :us:preBuild UP-TO-DATE
  :us:preStageDebugBuild UP-TO-DATE
  :datePickerLibrary:copyReleaseLint
  :us:checkStageDebugManifest UP-TO-DATE
  :datePickerLibrary:preBuild UP-TO-DATE
  :us:preStageReleaseBuild UP-TO-DATE
  :datePickerLibrary:preReleaseBuild UP-TO-DATE
  :us:generateStageDebugBuildConfig
  :datePickerLibrary:checkReleaseManifest
  :datePickerLibrary:preDebugAndroidTestBuild UP-TO-DATE
  :datePickerLibrary:preDebugBuild UP-TO-DATE
  :datePickerLibrary:preDebugUnitTestBuild UP-TO-DATE
  :us:generateStageDebugResValues
  :us:generateStageDebugBuildConfig UP-TO-DATE
  :datePickerLibrary:preReleaseUnitTestBuild
  :us:processStageDebugGoogleServices UP-TO-DATE
  File google-services.json is missing from module root folder. The Google Quickstart Plugin cannot function without it.
          :datePickerLibrary:prepareComAndroidSupportSupportV132100Library
  :us:generateStageDebugAssets UP-TO-DATE
  :us:processStageDebugJavaRes UP-TO-DATE
  :datePickerLibrary:prepareComAndroidSupportSupportV132100Library UP-TO-DATE
  :us:compileStageDebugNdk
  :datePickerLibrary:prepareComAndroidSupportSupportV42100Library UP-TO-DATE
  :us:newRelicInstrumentTask UP-TO-DATE
  :us:compileStageDebugNdk UP-TO-DATE
  :api:processResources UP-TO-DATE
  [newrelic.info] Detected cached instrumentation.
  :datePickerLibrary:prepareReleaseDependencies
  :api:classes UP-TO-DATE
  :api:jar
  :datePickerLibrary:compileReleaseAidl UP-TO-DATE
  :datePickerLibrary:compileReleaseRenderscript UP-TO-DATE
  :datePickerLibrary:prepareReleaseDependencies UP-TO-DATE
  :datePickerLibrary:generateReleaseBuildConfig UP-TO-DATE
  :datePickerLibrary:generateReleaseAssets UP-TO-DATE
  :datePickerLibrary:mergeReleaseAssets UP-TO-DATE
  :datePickerLibrary:generateReleaseResValues UP-TO-DATE
  :datePickerLibrary:generateReleaseResources UP-TO-DATE
  :datePickerLibrary:mergeReleaseResources
  :us:validateDebugSigning UP-TO-DATE
  :datePickerLibrary:processReleaseManifest UP-TO-DATE
  :datePickerLibrary:processReleaseResources UP-TO-DATE
  :datePickerLibrary:generateReleaseSources UP-TO-DATE
  :datePickerLibrary:processReleaseJavaRes UP-TO-DATE
  :datePickerLibrary:compileReleaseJavaWithJavac UP-TO-DATE
  :datePickerLibrary:extractReleaseAnnotations UP-TO-DATE
  :datePickerLibrary:mergeReleaseProguardFiles UP-TO-DATE
  :datePickerLibrary:packageReleaseJar UP-TO-DATE
  :datePickerLibrary:compileReleaseNdk UP-TO-DATE
  :datePickerLibrary:packageReleaseJniLibs UP-TO-DATE
  :datePickerLibrary:packageReleaseLocalJar UP-TO-DATE
  :datePickerLibrary:packageReleaseRenderscript UP-TO-DATE
  :datePickerLibrary:packageReleaseResources UP-TO-DATE
  :datePickerLibrary:bundleRelease UP-TO-DATE
  :us:prepareAndroidClientDatePickerLibraryUnspecifiedLibrary UP-TO-DATE
  :us:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
  :us:prepareComAndroidSupportCardviewV72221Library UP-TO-DATE
  :us:prepareComAndroidSupportDesign2221Library UP-TO-DATE
  :us:prepareComAndroidSupportMultidex101Library UP-TO-DATE
  :us:prepareComAndroidSupportRecyclerviewV72221Library UP-TO-DATE
  :us:prepareComAndroidSupportSupportV132221Library UP-TO-DATE
  :us:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
  :us:prepareComFacebookAndroidFacebookAndroidSdk3230Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
  :us:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
  :us:prepareComInstabugLibraryInstabugcore17Library UP-TO-DATE
  :us:prepareComInstabugLibraryInstabugsupport17Library UP-TO-DATE
  :us:prepareComMixpanelAndroidMixpanelAndroid462Library UP-TO-DATE
  :us:prepareComRengwuxianMaterialedittextLibrary214Library UP-TO-DATE
  :us:prepareComRoomoramaCaldroid220Library UP-TO-DATE
  :us:prepareComZendeskSdk1322Library UP-TO-DATE
  :us:prepareUkCoChrisjenxCalligraphy201Library UP-TO-DATE
  :us:prepareStageDebugDependencies
  :us:compileStageDebugAidl UP-TO-DATE
  :us:compileStageDebugRenderscript UP-TO-DATE
  :us:generateStageDebugResources
  :us:mergeStageDebugResources UP-TO-DATE
  :us:jrebelPinStageDebugResids UP-TO-DATE
  :us:mergeStageDebugAssets UP-TO-DATE
  :us:processStageDebugManifest UP-TO-DATE
  :us:processStageDebugResources UP-TO-DATE
  :us:generateStageDebugSources UP-TO-DATE
  :us:compileStageDebugJavaWithJavac UP-TO-DATE
  :us:compileStageDebugSources UP-TO-DATE
  :us:generateStageDebugJrebelLayout
  :us:preDexStageDebug UP-TO-DATE
  :us:dexStageDebug UP-TO-DATE
  :us:newRelicDeinstrumentTask
  [newrelic.info] Deinstrumenting...
          :us:jrebelPostProcessStageDebugResids UP-TO-DATE
  :us:packageStageDebug UP-TO-DATE
  :us:zipalignStageDebug UP-TO-DATE
  :us:assembleStageDebug
  
  BUILD SUCCESSFUL
  
  Total time: 8.54 secs
  </code></pre>
  
  <p>I attached the build logs from both</p>