title: How to define variants in Android Studio for development and release application for React Native application
body: <p>I use react-native-config for changing between production and development environments.</p>
  <p>I can switch environments dev/prod (bundler identifier, appIcon, splashScreeen, appName, ..) base on the scheme for IOS</p>
  <p>for dev:</p>
  <pre><code>ENVFILE=.env npx react-native run-ios --scheme 'testConfigAppDev'
  </code></pre>
  <p>and for prod:</p>
  <pre><code>ENVFILE=.env.production npx react-native run-ios --scheme 'testConfigApp'
  </code></pre>
  <p>If I want to use it similar to android:</p>
  <p>for dev:</p>
  <pre><code>ENVFILE=.env npx react-native run-android --variant debug
  </code></pre>
  <p>and for prod:</p>
  <pre><code>ENVFILE=.env.production npx react-native run-ios --scheme 'testConfigApp'
  </code></pre>
  <p>I want to have under one project two types of app dev and prod with applicationId e.g: <strong>com.my.app</strong> for production and <strong>com.my.app.dev</strong> for development</p>
  <p>I want to switch environments dev/prod (bundler identifier, appIcon, splashScreeen, appName, ..)</p>
  <p>But I every time build the same application with the same appIcon and appName.</p>
  <p>in Android/app/build.gradle:</p>
  <pre><code>android {
      compileSdkVersion rootProject.ext.compileSdkVersion
  
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
  
      defaultConfig {
          //applicationId project.env.get(&quot;APP_ID&quot;)
          minSdkVersion rootProject.ext.minSdkVersion
          targetSdkVersion rootProject.ext.targetSdkVersion
          versionCode 1
          versionName &quot;1.0&quot;
          resValue &quot;string&quot;, &quot;app_name&quot;, project.env.get(&quot;APP_DISPLAY_NAME&quot;)
          resValue &quot;string&quot;, &quot;build_config_package&quot;, project.env.get(&quot;APP_ID&quot;)
      }
      splits {
          abi {
              reset()
              enable enableSeparateBuildPerCPUArchitecture
              universalApk false  // If true, also generate a universal APK
              include &quot;armeabi-v7a&quot;, &quot;x86&quot;, &quot;arm64-v8a&quot;, &quot;x86_64&quot;
          }
      }
      signingConfigs {
          debug {
              storeFile file('debug.keystore')
              storePassword 'android'
              keyAlias 'androiddebugkey'
              keyPassword 'android'
          }
      }
      buildTypes {
          debug {
              signingConfig signingConfigs.debug
              debuggable true
              applicationIdSuffix &quot;.dev&quot;
          }
          release {
              // Caution! In production, you need to generate your own keystore file.
              // see https://reactnative.dev/docs/signed-apk-android.
              signingConfig signingConfigs.debug
              minifyEnabled enableProguardInReleaseBuilds
              proguardFiles getDefaultProguardFile(&quot;proguard-android.txt&quot;), &quot;proguard-rules.pro&quot;
          }
      }
  
      // applicationVariants are e.g. debug, release
      applicationVariants.all { variant -&gt;
          variant.outputs.each { output -&gt;
              // For each separate APK per architecture, set a unique version code as described here:
              // https://developer.android.com/studio/build/configure-apk-splits.html
              def versionCodes = [&quot;armeabi-v7a&quot;: 1, &quot;x86&quot;: 2, &quot;arm64-v8a&quot;: 3, &quot;x86_64&quot;: 4]
              def abi = output.getFilter(OutputFile.ABI)
              if (abi != null) {  // null for the universal-debug, universal-release variants
                  output.versionCodeOverride =
                          versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
              }
  
          }
      }
  }
  </code></pre>
  <p>My goal is to build an application for production with application_id com.my.app and development com.my.app.dev.</p>
  <p>Thank guys for your help.</p>