title: React Native build fails on building a new build type other than debug/release
body: <p>I am trying to prepare a staging release build but by my build is failing. It gives me a huge list of errors. I have modified my build.gradle to add a staging environment. I am not sure why this is happening as my debug and release build works fine.  </p>
  
  <p>I used <code>yarn android --variant=stagingrelease</code> to generate the build and run on my physical android device. Using <code>React-Native: 0.61.5</code>.</p>
  
  <p><strong>Some of the errors are as follows</strong>  </p>
  
  <pre><code>FAILURE: Build failed with an exception.
  
  * What went wrong: Could not determine the dependencies of task ':app:preStagingreleaseBuild'.
  &gt; Could not resolve all task dependencies for configuration ':app:stagingreleaseRuntimeClasspath'.
     &gt; Could not resolve project :@react-native-community_masked-view.
       Required by:
           project :app
        &gt; Unable to find a matching variant of project :@react-native-community_masked-view:
            - Variant 'debugApiElements' capability Furry:@react-native-community_masked-view:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'debugRuntimeElements' capability Furry:@react-native-community_masked-view:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
            - Variant 'releaseApiElements' capability Furry:@react-native-community_masked-view:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'releaseRuntimeElements' capability Furry:@react-native-community_masked-view:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
     &gt; Could not resolve project :react-native-bootsplash.
       Required by:
           project :app
        &gt; Unable to find a matching variant of project :react-native-bootsplash:
            - Variant 'debugApiElements' capability Furry:react-native-bootsplash:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'debugRuntimeElements' capability Furry:react-native-bootsplash:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
            - Variant 'releaseApiElements' capability Furry:react-native-bootsplash:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'releaseRuntimeElements' capability Furry:react-native-bootsplash:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
     &gt; Could not resolve project :react-native-config.
       Required by:
           project :app
        &gt; Unable to find a matching variant of project :react-native-config:
            - Variant 'debugApiElements' capability Furry:react-native-config:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'debugRuntimeElements' capability Furry:react-native-config:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
            - Variant 'releaseApiElements' capability Furry:react-native-config:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'releaseRuntimeElements' capability Furry:react-native-config:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
     &gt; Could not resolve project :react-native-gesture-handler.
       Required by:
           project :app
        &gt; Unable to find a matching variant of project :react-native-gesture-handler:
            - Variant 'debugApiElements' capability Furry:react-native-gesture-handler:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'debugRuntimeElements' capability Furry:react-native-gesture-handler:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
            - Variant 'releaseApiElements' capability Furry:react-native-gesture-handler:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'releaseRuntimeElements' capability Furry:react-native-gesture-handler:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
     &gt; Could not resolve project :react-native-reanimated.
       Required by:
           project :app
        &gt; Unable to find a matching variant of project :react-native-reanimated:
            - Variant 'debugApiElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'debugRuntimeElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
            - Variant 'releaseApiElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'releaseRuntimeElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
     &gt; Could not resolve project :react-native-safe-area-context.
       Required by:
           project :app
        &gt; Unable to find a matching variant of project :react-native-safe-area-context:
            - Variant 'debugApiElements' capability Furry:react-native-safe-area-context:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'debugRuntimeElements' capability Furry:react-native-safe-area-context:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
            - Variant 'releaseApiElements' capability Furry:react-native-safe-area-context:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'releaseRuntimeElements' capability Furry:react-native-safe-area-context:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
     &gt; Could not resolve project :react-native-screens.
       Required by:
           project :app
        &gt; Unable to find a matching variant of project :react-native-screens:
            - Variant 'debugApiElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'debugRuntimeElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
            - Variant 'releaseApiElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
                - Incompatible attributes:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                    - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Variant 'releaseRuntimeElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
                - Incompatible attribute:
                    - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                - Other attributes:
                    - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                    - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                    - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
  </code></pre>
  
  <p><strong>Snippets of android/app/build.gradle</strong>  </p>
  
  <pre><code>project.ext.envConfigFiles = [
          debug: ".env",
          release: ".env.production",
          stagingrelease: ".env.staging",
  ]
  apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
  
  project.ext.react = [
      entryFile: "index.js",
      enableHermes: false,  // clean and rebuild if changing
  ]
  
  apply from: "../../node_modules/react-native/react.gradle"
  
  def enableSeparateBuildPerCPUArchitecture = false
  
  def enableProguardInReleaseBuilds = true
  
  def enableHermes = project.ext.react.get("enableHermes", false);
  
  android {
      compileSdkVersion rootProject.ext.compileSdkVersion
  
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
  
      defaultConfig {
          applicationId "com.furry"
          minSdkVersion rootProject.ext.minSdkVersion
          targetSdkVersion rootProject.ext.targetSdkVersion
          versionCode 1
          versionName "1.0"
      }
      splits {
          abi {
              reset()
              enable enableSeparateBuildPerCPUArchitecture
              universalApk false  // If true, also generate a universal APK
              include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
          }
      }
      signingConfigs {
          debug {
              storeFile file('debug.keystore')
              storePassword 'android'
              keyAlias 'androiddebugkey'
              keyPassword 'android'
          }
      }
      buildTypes {
          debug {
              signingConfig signingConfigs.debug
          }
          release {
              // Caution! In production, you need to generate your own keystore file.
              // see https://facebook.github.io/react-native/docs/signed-apk-android.
              signingConfig signingConfigs.debug
              minifyEnabled enableProguardInReleaseBuilds
              proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
          }
          stagingrelease {
              initWith release
          }
      }
  
  dependencies {
      implementation fileTree(dir: "libs", include: ["*.jar"])
      implementation "com.facebook.react:react-native:+"  // From node_modules
      implementation "androidx.appcompat:appcompat:1.1.0-rc01"
      implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02"
  
      if (enableHermes) {
          def hermesPath = "../../node_modules/hermes-engine/android/";
          debugImplementation files(hermesPath + "hermes-debug.aar")
          releaseImplementation files(hermesPath + "hermes-release.aar")
      } else {
          implementation jscFlavor
      }
  }
  
  
  apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
  project.ext.vectoricons = [
      iconFontNames: [ 'MaterialIcons.ttf', 'MaterialCommunityIcons.ttf' ]
  ]
  apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
  </code></pre>
  
  <p><strong>android/build.gradle</strong>  </p>
  
  <pre><code>allprojects {
      repositories {
          mavenLocal()
          maven {
              // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
              url("$rootDir/../node_modules/react-native/android")
          }
          maven {
              // Android JSC is installed from npm
              url("$rootDir/../node_modules/jsc-android/dist")
          }
  
          google()
          jcenter()
          maven { url 'https://jitpack.io' }
      }
  }
  </code></pre>
  
  <p><strong>proguard-rules.pro</strong>  </p>
  
  <pre><code># Add any project specific keep options here:
  -keep class com.furry.BuildConfig { *; }
  </code></pre>
  
  <p><strong>Dependencies in package.json</strong>  </p>
  
  <pre><code>"dependencies": {
          "@react-native-community/masked-view": "^0.1.6",
          "@react-navigation/native": "^5.0.7",
          "@react-navigation/stack": "^5.0.8",
          "axios": "^0.19.2",
          "libphonenumber-js": "^1.7.44",
          "react": "16.9.0",
          "react-native": "0.61.5",
          "react-native-bootsplash": "^1.2.1",
          "react-native-config": "^0.12.0",
          "react-native-gesture-handler": "^1.6.0",
          "react-native-reanimated": "^1.7.0",
          "react-native-safe-area-context": "^0.7.3",
          "react-native-screens": "^2.0.0-beta.10",
          "react-native-sms-retriever": "^1.1.1",
          "react-native-svg": "^11.0.1",
          "react-native-vector-icons": "^6.6.0",
          "realm": "4.0.0-beta.0",
          "recyclerlistview": "2.0.13-alpha.1"
      },
  </code></pre>