Home > Web Front-end > JS Tutorial > Why are my React Native Android builds failing after upgrading to version 0.71.0-rc.0?

Why are my React Native Android builds failing after upgrading to version 0.71.0-rc.0?

Barbara Streisand
Release: 2024-12-05 06:13:11
Original
1014 people have browsed it

Why are my React Native Android builds failing after upgrading to version 0.71.0-rc.0?

React Native Android Build Failures Due to React Native Version 0.71.0-rc.0

Problem:

Recently, users have encountered various errors when building their React Native Android apps, despite not making any code changes. These errors may manifest differently, but they typically involve failed installations or unresolved dependency issues.

Analysis:

Cause:

The root cause of these build failures lies in the recent publication of React Native version 0.71.0-rc.0. This update introduces dependencies that conflict with existing configurations in the Android build system.

Solution:

Method 1:

Modify your Android build.gradle file to force the use of the local React Native library within the node_modules directory. Add the following code:

buildscript {
    // ...
}

allprojects {
    repositories {
       exclusiveContent {
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }
        // ...
    }
}
Copy after login

Method 2:

If your gradle file does not support the exclusiveContent rule, add the following code 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
          }
    }
    // ...  
}
Copy after login

Additional Note:

Before applying these fixes, it is recommended to revert any recent changes you have made to your code.

Reference:

For detailed explanations and fixes, please refer to the official update on Android build failures: https://github.com/facebook/react-native/issues/35210

The above is the detailed content of Why are my React Native Android builds failing after upgrading to version 0.71.0-rc.0?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template