Home >Web Front-end >JS Tutorial >Why is My React Native Android Build Failing After Updating to 0.71.0-rc.0?
React Native Android Build Failure After Release of Version 0.71.0-rc.0
Since the recent release of React Native version 0.71.0-rc.0, Android build failures have been a common issue for developers, despite no changes in their code.
Potential Failures:
Although the error messages may vary, the underlying cause is typically related to the conflicting versions of the React Native library in the node_modules and the Android build.
Solution:
To resolve this issue, two methods can be implemented:
Method 1:
buildscript { // ... } allprojects { repositories { exclusiveContent { filter { includeGroup "com.facebook.react" } forRepository { maven { url "$rootDir/../node_modules/react-native/android" } } } // ... } }
Method 2:
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 methods will force Gradle to use the React Native library version from your node_modules directory, resolving the conflicts and allowing your Android build to succeed.
The above is the detailed content of Why is My React Native Android Build Failing After Updating to 0.71.0-rc.0?. For more information, please follow other related articles on the PHP Chinese website!