React Native Android Build Fails with Various Errors Despite No Code Changes Due to React Native 0.71.0-rc.0 Release
Problem:
Users are experiencing Android build failures with varying error messages, despite not making any code changes in the past few days. The issue seems to have arisen after the release of React Native version 0.71.0-rc.0.
Cause:
The build failures are caused by the recent release of React Native 0.71.0-rc.0.
Solution:
To resolve the issue, try one of the following methods:
Method 1:
Add this fix to your android/build.gradle file:
buildscript { // ... } allprojects { repositories { exclusiveContent { filter { includeGroup "com.facebook.react" } forRepository { maven { url "$rootDir/../node_modules/react-native/android" } } } // ... } }
Method 2:
If your gradle version does not support the first method, add this to your android/build.gradle file instead:
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()) buildscript { // ... } allprojects { configurations.all { resolutionStrategy { force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION } } // ... }
These fixes force the resolution of the React Native Android library to use the one inside the node_modules directory, resolving the issue.
The above is the detailed content of Why is My React Native Android Build Failing After Upgrading to 0.71.0-rc.0?. For more information, please follow other related articles on the PHP Chinese website!