Lompat ke konten Lompat ke sidebar Lompat ke footer

React Native error: Execution failed for task 'app:checkDebugAarMetadata'


As we now know rn is version 0.70, with the development that is always so fast, sometimes we need additional time to upgrade the rn version in our project, and sometimes we have to stick to the rn version that we are using now because of many considerations.

Now I want to share about the rn update on November 4th which made the developers get an error; yes, the error is due to an update on rn which requires us to update the build.gradle for the rn version below 0.63 and update the rn version for several rn versions above the version 0.63.

React Native >= 0.63

We have prepared releases for all the main versions of react-native with a hotfix:

After updating these patch versions, your Android build should start working again.

To do so, in your package.json change react-native's version to the relevant new patch (ex. If you are on 0.64.3, change to 0.64.4) and run yarn install. No other changes should be necessary, but you might want to clean your android artifacts with a cd android and ./gradlew clean before trying to re-run your Android app.

React Native < 0.63

The fix above only works on gradle 6.2 and higher. Older react-native used older gradle.

You may determine your gradle version by looking in your /android/gradle/wrapper/gradle-wrapper.properties file.

If you are on an older version of react-native (for example 0.63 or earlier) that uses gradle version 6.1 or below, you must use a different workaround as gradle 6.1 does not support exclusiveContent.

Add this in the allprojects area of your android/buld.gradle file.
 Instead of using exclusiveContent, the hotfix must force the version of React Native. The recommended hotfix shells out to node to read your current version of react-native. If you hard code the version of react-native, when you upgrade your project in the future, your build will fail if you forget to remove this hotfix.

 def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())


  allprojects {
      configurations.all {
          resolutionStrategy {
              // Remove this override in 0.65+, as a proper fix is included in react-native itself.
              force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
          }
      } 

Note that this fix is fragile as the location of your package.json could be different if you are in a monorepo, and node might not be available if you use a node package manager like nvm.


Posting Komentar untuk "React Native error: Execution failed for task 'app:checkDebugAarMetadata'"