Home > Web Front-end > JS Tutorial > Why is My React Native Android Build Failing After Upgrading to 0.71.0-rc.0?

Why is My React Native Android Build Failing After Upgrading to 0.71.0-rc.0?

Susan Sarandon
Release: 2024-12-05 07:27:09
Original
953 people have browsed it

Why is My React Native Android Build Failing After Upgrading to 0.71.0-rc.0?

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"
               }
           }
       }
        // ...
    }
}
Copy after login

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
          }
    }
    // ...  
}
Copy after login

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!

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