title: Error "Could not create task ':app:mergeDebugResources'" during building after upgrading React-Native up to 0.59.0
body: <p>Project doesn't build by command 'react-native run-android' after upgrading react-native from 0.57.1 to 0.59.0. 
  Gradle was upgrading in accordance with react-native 0.59.9 changelog: <code>"future-proof" RN 59 from crashes caused by upgrading Gradle (now can support up to 5.4.1 &amp; 3.4.0 for the plugin)</code></p>
  
  <p>Error</p>
  
  <pre><code>FAILURE: Build failed with an exception.
  
  * Where:
  Build file 'D:\Git\limepay-rn\android\build.gradle' line: 39
  
  * What went wrong:
  A problem occurred configuring project ':app'.
  &gt; Could not create task ':app:mergeDebugResources'.
     &gt; Project#beforeEvaluate(Closure) on project ':app' cannot be executed in the current context.
  </code></pre>
  
  <p>In the Internet and here, on the stackoverflow, they write about changing gradle versions. I tried different combinations of its versions (including those that people designate as workable), but every time there was this error. Clearing the gradle cache did not help either.</p>
  
  <p>Stacktrace</p>
  
  <pre><code>0 info it worked if it ends with ok
  1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
  1 verbose cli   'C:\\Users\\Kate\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
  1 verbose cli   'run',
  1 verbose cli   'android',
  1 verbose cli   '--stacktrace' ]
  2 info using npm@6.5.0
  3 info using node@v10.16.0
  4 verbose run-script [ 'preandroid', 'android', 'postandroid' ]
  5 info lifecycle LimePay@1.0.2~preandroid: LimePay@1.0.2
  6 info lifecycle LimePay@1.0.2~android: LimePay@1.0.2
  7 verbose lifecycle LimePay@1.0.2~android: unsafe-perm in lifecycle true
  8 verbose lifecycle LimePay@1.0.2~android: PATH: C:\Users\Kate\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Git\limepay-rn\node_modules\.bin;D:\Git\limepay-rn\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\WINDOWS\System32\OpenSSH\;C:\Android\tools;C:\platform-tools;C:\src\flutter\bin;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\GitExtensions\;C:\Program Files (x86)\dotnet\;C:\Program Files\nodejs\;C:\Users\Kate\AppData\Local\Microsoft\WindowsApps;C:\Users\Kate\AppData\Roaming\npm
  9 verbose lifecycle LimePay@1.0.2~android: CWD: D:\Git\limepay-rn
  10 silly lifecycle LimePay@1.0.2~android: Args: [ '/d /s /c', 'react-native run-android' ]
  11 silly lifecycle LimePay@1.0.2~android: Returned: code: 1  signal: null
  12 info lifecycle LimePay@1.0.2~android: Failed to exec android script
  13 verbose stack Error: LimePay@1.0.2 android: `react-native run-android`
  13 verbose stack Exit status 1
  13 verbose stack     at EventEmitter.&lt;anonymous&gt; (C:\Users\Kate\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
  13 verbose stack     at EventEmitter.emit (events.js:198:13)
  13 verbose stack     at ChildProcess.&lt;anonymous&gt; (C:\Users\Kate\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
  13 verbose stack     at ChildProcess.emit (events.js:198:13)
  13 verbose stack     at maybeClose (internal/child_process.js:982:16)
  13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
  14 verbose pkgid LimePay@1.0.2
  15 verbose cwd D:\Git\limepay-rn
  16 verbose Windows_NT 10.0.17134
  17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Kate\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "android" "--stacktrace"
  18 verbose node v10.16.0
  19 verbose npm  v6.5.0
  20 error code ELIFECYCLE
  21 error errno 1
  22 error LimePay@1.0.2 android: `react-native run-android`
  22 error Exit status 1
  23 error Failed at the LimePay@1.0.2 android script.
  23 error This is probably not a problem with npm. There is likely additional logging output above.
  24 verbose exit [ 1, true ]
  </code></pre>
  
  <p>android\build.gradle</p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      ext {
          buildToolsVersion = "28.0.3"
          minSdkVersion = 21
          compileSdkVersion = 28
          targetSdkVersion = 28
          supportLibVersion = "25.4.0"
          googlePlayServicesVersion = "12.0.1"
      }
      repositories {
          jcenter()
          google()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.3.0'
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          mavenLocal()
          jcenter()
          maven {
              // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
              url "$rootDir/../node_modules/react-native/android"
          }
          google()
          maven {
              // Android patched JS core for mobx v5 support
              // Local Maven repo containing AARs with JSC library built for Android
              url "$rootDir/../node_modules/jsc-android/dist"
         }
      }
    project.configurations.all {
        beforeEvaluate {project -&gt;
          if (project.hasProperty("android")) {
              android {
                  compileSdkVersion 25
                  buildToolsVersion '25.4.0'
              }
          }
      }
       resolutionStrategy.eachDependency { details -&gt;
          if (details.requested.group == 'com.android.support'
                &amp;&amp; !details.requested.name.contains('multidex') ) {
             details.useVersion "25.4.0"
          }
       }
    }
  }
  
  
  
  wrapper {
      gradleVersion = '5.4.1'
      distributionUrl = distributionUrl.replace("bin", "all")
  }
  
  </code></pre>
  
  <p>app\build.gradle</p>
  
  <pre><code>apply plugin: "com.android.application"
  
  import com.android.build.OutputFile
  
  /**
   * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
   * and bundleReleaseJsAndAssets).
   * These basically call `react-native bundle` with the correct arguments during the Android build
   * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
   * bundle directly from the development server. Below you can see all the possible configurations
   * and their defaults. If you decide to add a configuration block, make sure to add it before the
   * `apply from: "../../node_modules/react-native/react.gradle"` line.
   *
   * project.ext.react = [
   *   // the name of the generated asset file containing your JS bundle
   *   bundleAssetName: "index.android.bundle",
   *
   *   // the entry file for bundle generation
   *   entryFile: "index.android.js",
   *
   *   // whether to bundle JS and assets in debug mode
   *   bundleInDebug: false,
   *
   *   // whether to bundle JS and assets in release mode
   *   bundleInRelease: true,
   *
   *   // whether to bundle JS and assets in another build variant (if configured).
   *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
   *   // The configuration property can be in the following formats
   *   //         'bundleIn${productFlavor}${buildType}'
   *   //         'bundleIn${buildType}'
   *   // bundleInFreeDebug: true,
   *   // bundleInPaidRelease: true,
   *   // bundleInBeta: true,
   *
   *   // whether to disable dev mode in custom build variants (by default only disabled in release)
   *   // for example: to disable dev mode in the staging build type (if configured)
   *   devDisabledInStaging: true,
   *   // The configuration property can be in the following formats
   *   //         'devDisabledIn${productFlavor}${buildType}'
   *   //         'devDisabledIn${buildType}'
   *
   *   // the root of your project, i.e. where "package.json" lives
   *   root: "../../",
   *
   *   // where to put the JS bundle asset in debug mode
   *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
   *
   *   // where to put the JS bundle asset in release mode
   *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
   *
   *   // where to put drawable resources / React Native assets, e.g. the ones you use via
   *   // require('./image.png')), in debug mode
   *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
   *
   *   // where to put drawable resources / React Native assets, e.g. the ones you use via
   *   // require('./image.png')), in release mode
   *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
   *
   *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
   *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
   *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
   *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
   *   // for example, you might want to remove it from here.
   *   inputExcludes: ["android/**", "ios/**"],
   *
   *   // override which node gets called and with what additional arguments
   *   nodeExecutableAndArgs: ["node"],
   *
   *   // supply additional arguments to the packager
   *   extraPackagerArgs: []
   * ]
   */
  
  project.ext.react = [
      entryFile: "index.js"
  ]
  
  apply from: "../../node_modules/react-native/react.gradle"
  apply from: "../../node_modules/react-native-sentry/sentry.gradle"
  
  /**
   * Set this to true to create two separate APKs instead of one:
   *   - An APK that only works on ARM devices
   *   - An APK that only works on x86 devices
   * The advantage is the size of the APK is reduced by about 4MB.
   * Upload all the APKs to the Play Store and people will download
   * the correct one based on the CPU architecture of their device.
   */
  def enableSeparateBuildPerCPUArchitecture = false
  
  /**
   * Run Proguard to shrink the Java bytecode in release builds.
   */
  def enableProguardInReleaseBuilds = false
  
  android {
      compileSdkVersion rootProject.ext.compileSdkVersion
      buildToolsVersion rootProject.ext.buildToolsVersion
  
      defaultConfig {
          applicationId "com.limepay"
          minSdkVersion rootProject.ext.minSdkVersion
          targetSdkVersion rootProject.ext.targetSdkVersion
          versionCode 6
          versionName "1.0.2"
          ndk {
              abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
          }
          renderscriptTargetApi 23 // Settings from package react-native-blur
          renderscriptSupportModeEnabled true // Settings from package react-native-blur
      }
      signingConfigs {
          release {
              if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                  storeFile file(MYAPP_RELEASE_STORE_FILE)
                  storePassword MYAPP_RELEASE_STORE_PASSWORD
                  keyAlias MYAPP_RELEASE_KEY_ALIAS
                  keyPassword MYAPP_RELEASE_KEY_PASSWORD
              }
          }
      }
      splits {
          abi {
              reset()
              enable enableSeparateBuildPerCPUArchitecture
              universalApk false  // If true, also generate a universal APK
              include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
          }
      }
      buildTypes {
          release {
              minifyEnabled enableProguardInReleaseBuilds
              proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
              signingConfig signingConfigs.release
          }
       // 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:
                  // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
                  def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 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
                  }
              }
          }
          }
  
  }
  
  dependencies {
      compile project(':react-native-sentry')
      implementation project(':react-native-webview')
      implementation project(':react-native-svg')
      implementation project(':react-native-linear-gradient')
      implementation project(':react-native-camera')
      implementation project(':react-native-blur')
      // implementation project(':react-native-awesome-card-io')
      implementation fileTree(dir: "libs", include: ["*.jar"])
      implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
      implementation "com.facebook.react:react-native:+"  // From node_modules
      implementation "com.google.android.gms:play-services-base:${rootProject.ext.googlePlayServicesVersion}" // react-native-maps
      implementation "com.google.android.gms:play-services-maps:${rootProject.ext.googlePlayServicesVersion}" // react-native-maps
      implementation project(':react-native-device-info')
  }
  
  // Run this once to be able to run the application with BUCK
  // puts all compile dependencies into folder libs for BUCK to use
  task copyDownloadableDepsToLibs(type: Copy) {
      from configurations.compile
      into 'libs'
  }
  
  // Version conflict fix
  configurations.all {
      resolutionStrategy {
          force "com.android.support:support-v4:${rootProject.ext.supportLibVersion}"
          force 'org.webkit:android-jsc:r224109' // For patched JS core mobx5 support
      }
  }
  
  </code></pre>
  
  <p>gradle-wrapper.properties</p>
  
  <pre><code>distributionBase=GRADLE_USER_HOME
  distributionPath=wrapper/dists
  zipStoreBase=GRADLE_USER_HOME
  zipStorePath=wrapper/dists
  distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
  </code></pre>
  
  <p>What I do wrong?</p>