Android Build Failures in React Native after Release of Version 0.71.0-rc.0
Recent Android build failures in React Native have been attributed to the publication of React Native version 0.71.0-rc.0. Even without code changes, users have encountered various error messages during the build process.
Method 1
Modify your android/build.gradle file by implementing the following fix:
buildscript { // ... } allprojects { repositories { exclusiveContent { filter { includeGroup "com.facebook.react" } forRepository { maven { url "$rootDir/../node_modules/react-native/android" } } } // ... } }
This fix introduces an exclusive resolution rule that compels the use of the React Native Android library within the node_modules directory.
Method 2
If Method 1 is incompatible with your gradle version, add the following to your android/build.gradle file:
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 } } // ... }
Refer to "Fix and updates on Android build failures happening since Nov 4th 2022 #35210" for details on this adjustment.
The above is the detailed content of React Native 0.71.0-rc.0 Android Build Failures: How Can I Fix Them?. For more information, please follow other related articles on the PHP Chinese website!