title: Setting process.env variable from Android Studio flavors
body: <p>I want to be able to access a variable in my <code>metro.config.js</code>.</p>
  
  <p>On iOS this can be achieved by adding a <em>User Defined</em> variable in the Build Settings tab. This is accessible with <code>process.env.MY_VAR</code>. The value of <code>MY_VAR</code> can be changed depending on which target is being built.</p>
  
  <p>How can I achieve the same for Android using product flavours?</p>
  
  <p>Here is my current setup</p>
  
  <pre><code>    flavorDimensions "apps"
      productFlavors {
          free {
              dimension "apps"
          }
          paid {
              dimension "apps"
          }
      }
  </code></pre>
  
  <p><strong>Execution Steps</strong></p>
  
  <p>When running iOS, I can see from the logs that the project gets built before the Packager starts</p>
  
  <pre><code>info Found Xcode workspace "foo.xcworkspace"
  info Building (using "xcodebuild -workspace foo.xcworkspace -configuration Debug -scheme foo -destination id=CE408502-CD8C-4467-AE3D-295081CAF132 -derivedDataPath build/foo") &lt;-- Build
  ▸ Running script '[CP-User] Config codegen'
  ▸ Compiling ReactNativeConfig.m
  ▸ Building library libreact-native-config.a
  ▸ Running script 'Upload Debug Symbols to Sentry'
  ▸ Running script 'Start Packager              &lt;-- Metro starts here
  </code></pre>
  
  <p>However, the packager starts before my gradle build task executes</p>
  
  <pre><code>info Starting JS server...                    &lt;-- Metro starts here
  info Installing the app...
  &gt; Configure project :app
  Reading env from: .env
  &gt; Task :app:installFreeDebug                  &lt;-- Build
  </code></pre>