react-native: [FIXED] Android build failures `No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found.`

Description

Hey all, I’d like to share an update on a series of build failures React Native & Expo users have been experiencing when building Android apps starting from November 4th 2022.

We’d like to apologize for the disruption this caused to your developer workflows. The React team is fully committed to delivering a smooth developer experience, and we take this type of issues extremely seriously.

📢 Patches for >= 0.63

We have prepared releases for all the main versions of react-native with an hotfix:

🛳 0.70.5: https://github.com/facebook/react-native/releases/tag/v0.70.5 🛳️ 0.69.7: https://github.com/facebook/react-native/releases/tag/v0.69.7 🛳 0.68.5: https://github.com/facebook/react-native/releases/tag/v0.68.5 🛳️ 0.67.5: https://github.com/facebook/react-native/releases/tag/v0.67.5 🛳️ 0.66.5: https://github.com/facebook/react-native/releases/tag/v0.66.5 🛳️ 0.65.3: https://github.com/facebook/react-native/releases/tag/v0.65.3 🛳️ 0.64.4: https://github.com/facebook/react-native/releases/tag/v0.64.4 🛳️ 0.63.5: https://github.com/facebook/react-native/releases/tag/v0.63.5

By updating to these patch versions, your Android build should start working again.

To do so, in your package.json change react-native’s version to the relevant new patch (ex. if you are on 0.64.3, change to 0.64.4) and run yarn install. No other changes should be necessary, but you might want to clean your android artifacts with a cd android && ./gradlew clean before trying to re-run your Android app.

Fix for older react-native (< 0.63)

The fix above only works on gradle 6.2 and higher. Older react-native used older gradle.

You may determine your gradle version by looking in your /android/gradle/wrapper/gradle-wrapper.properties file.

If you are on an older version of react-native (for example 0.63 or earlier) that uses gradle version 6.1 or below, you must use a different workaround as gradle 6.1 does not support exclusiveContent.

Add this in the allprojects area of your android/buld.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())

allprojects {
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.65+, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }

Instead of using exclusiveContent, the hotfix must force the version of React Native. The recommended hotfix shells out to node to read your current version of react-native. If you hard code the version of react-native, when you upgrade your project in the future, your build will fail if you forget to remove this hotfix.

Note that this fix is fragile as the location of your package.json could be different if you are in a monorepo, and node might not be available if you use a node package manager like nvm.

Thank you @mikehardy for finding and providing this fix in your comment.

Technical Details

The issue

On November 4th 2022 we published the React Native version 0.71.0-rc0, the first release candidate for the 71 release series, on several public repositories. Specifically, this version was also published on Maven Central as we’re updating our artifacts distribution strategy (technical details are explained below).

This event resulted in build failures for Android on several users as they ended up downloading the wrong React Native version (0.71.0-rc0 instead of the version they were using in their project, say 0.68.0).

The build error looks something like this:

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'My Project'.
Could not determine the dependencies of null.
Could not resolve all task dependencies for configuration ':classpath'.
    > Could not resolve com.facebook.react:react-native:+.
      Required by:
          project :
    > No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found. 
      The consumer was configured to find a runtime of a library compatible with Java 11, 
      packaged as a jar, and its dependencies declared externally, as well 
      as attribute 'org.gradle.plugin.api-version' with value '7.3.3' but:

Sadly, due to how older projects of React Native were created in the past, we couldn’t simply re-publish older versions, and we’re asking users to update their template using the fix suggested below.

Why this happened

Historically, the React Native template provided build.gradle files that contain a dependency on the React Native Android library as follows: implementation("com.facebook.react:react-native:+").

Specifically, the + part of this dependency declaration is causing Gradle to pick the highest version among all the declared repositories (often referred as Gradle Dynamic versions). Till React Native version 0.70, we were shipping a Maven Repository inside the NPM package (inside the ./android folder). Starting from 0.71, we moved such folder and uploaded it to Maven Central.

Using Gradle Dynamic versions (i.e. a + dependency) is considered an antipattern (see the various warnings and notes on this page), specifically as it can lead to scenarios like this one and generally exposes users to less-reproducible builds. This is exactly what happened in this scenario, as builds started failing without any changes to user projects.

In 0.71 we cleaned up the new app template and removed all the + dependencies (see here) and we moved the template to use the React Native Gradle Plugin, which will allow us to prevent scenarios like this from happening in the future.

Sadly, users on older versions, say 0.66.0, were still using a + version. This caused their build to query all the repositories for the highest available versions of the React Native. While the node_modules/react-native/android folder contained a valid 0.66.0 version, Gradle honoured the + version and fetched version 0.71.0-rc0 from Maven Central as it’s higher from the semantic versioning ordering.

The resolutionStrategy block in the fix is forcing the version of com.facebook.react:react-native to all the projects to the one provided by the version of React Native you’re effectively using.

Who is affected?

All the React Native users on versions till 0.66.x are affected.

React Native users on versions from 0.67 till 0.70 could be affected, based on which third-party library they’re using.

We verified that empty projects created on versions from 0.67 till 0.70 are not affected.

However, some of your dependencies might end up causing a wrong resolution of the React Native Android library, resulting in build failures. For instance, we verified that a project on React Native 0.68.4 works well with Reanimated 2.12.0 but fails with Reanimated 2.10.0.

We also worked with Expo to make sure that users on eas build received the aforementioned fix, so those users should not be affected.

Why React Native Android was published on Maven Central?

As mentioned, this was done as part of the implementation of the RFC #580.

The summary of that RFC is to allow us to overcome the limitation of NPM in terms of package size. Moving to Maven Central will allow us to reduce the build time for our users and distribute more granular artifacts which will end up benefitting the overall developer experience. We’ll be able to share information on this in the near future.

In the initial Github Issue, several users suggest to remove the publishing from Maven Central or re-publish older artifacts to overcome the build failure without requesting a fix.

This is sadly not an option as:

  1. Maven Central is an immutable artifacts storage and doesn’t allow deletion.
  2. The publishing on 0.71.0-rc0 was effectively correct. We believe this episode is essentially a “mis-configuration” in user projects, and we believe the better solution is to distribute this fix to our users.

How could this have been prevented

We were already aware of the risk of having Gradle dynamic dependencies, so since React Native 0.67 we introduced an exclude rule on the Maven Central dependency inside the default template (see here for more context):

        mavenCentral {
            content {
                excludeGroup("com.facebook.react")
            }
        }

React Native used to be published on Maven Central till version 0.20.1 (published in 2016). We had users in the past accidentally fetching older versions of React from Maven Central, causing their build to fail.

This exclude directive assured that you won’t ever download React Native from Maven Central. However, third party libraries could declare repositories inside their repositories{} block which might not contain the exclude directive, resulting in potentially broken dependency resolution.

React Native version 0.71.0 will ship with an updated template that relies on React Native Gradle Plugin. This new integration will allow us to protect us against future distributed build failures like this one, by allowing to re-distribute updated build logic across the whole ecosystem if needed (this should protect us also against similar outages like the JCenter outage happened last year).


I’d like to thank everyone for your patience and understanding and I’d like to call out some members our our community, specifically @mikehardy, @Titozzz, @brentvatne, @inckie and all the other folks involved in the initial investigation and fix for this issue.

We’ll follow up with more updates in the future if needed.

Nicola On behalf of the React team

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 913
  • Comments: 220 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@JodiRaina that likely indicates your gradle plugin or gradle is too old to use this advice - it appears gradle 6.1 and older does not have the exclusiveContent / include filter in the preferred solution.

If you cannot upgrade gradle (and react-native…), you might try one of the fallback workarounds for old react-native using very old gradle plugin / gradle, specifically this one, which was the best-known solution if exclusiveContent is not available / until the exclusiveContent idea occurred

https://github.com/facebook/react-native/issues/35204#issuecomment-1304281740


@brentvatne @ Expo proposes this as a refinement to avoid the hard coded version, it is the same as the previous best-known solution but now with dynamic version powers, otherwise same idea - you put this in the allprojects area of your android/buld.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())

allprojects {
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.66, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }

Note that the exclusiveContent idea is a cleaner solution, but of course only if your gradle supports it

Hey everyone 👋 ! We know the fix works in almost all cases. We have one failure case where your gradle is 6.1 or lower, with a separate workaround as described above.

There is no need to report success here as it will just clutter up the thread and hide real problems, if any.

If you have a case that does not work, then it is worth commenting and pursuing.

Thanks!

I am having the same problem with this version 0.64.0. I tried to figure it out but still can not figure out

try this bro : build.gradle

allprojects {
    repositories {
       exclusiveContent {
           // We get React Native's Android binaries exclusively through npm,
           // from a local Maven repo inside node_modules/react-native/.
           // (The use of exclusiveContent prevents looking elsewhere like Maven Central
           // and potentially getting a wrong version.)
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }    
               
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        mavenCentral {
            content {
                excludeGroup("com.facebook.react")
            }
        }        

    

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

then remove node modules, npm install, run gradlew clean in android directory, and run apps

We yesterday faced with this issue too

fixed easy:

in android/app/build.gradle

replace

implementation “com.facebook.react:react-native:+”

to

implementation (“com.facebook.react:react-native”) version { strictly “0.69.3” }

NB: Use exact RN version from you project’s package.json instead of “0.69.3” This fix force Gradle to use exact version of RN instead of 0.70.x for the all modules in project

Hello All,

React Native Version : 0.63.0

Firstly I got

.gradle/caches/transforms-2/files-2.1/fbb7a340b18cb1ab123bd8116e2b4a16/core-1.7.0/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

I tried the below solution as recommended by @anhkieet

Add this in the allprojects area of your android/buld.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())

allprojects { configurations.all { resolutionStrategy { // Remove this override in 0.65+, as a proper fix is included in react-native itself. force “com.facebook.react:react-native:” + REACT_NATIVE_VERSION } }

Then got the below issue : Cause: react_dbl48axvbt6e0k1c9t3iq8qv8$_run_closure4$_closure6$_closure10$_closure18

Then deleted global .gradle file from system and restarted android studio through invalidate cache and restart and it worked finally.

Thank you @anhkieet

ANYONE WITH VERSION 0.63.0 CAN TRY THE ABOVE SOLUTION 😃

This solution worked for me Added this project build.gradle, in allProjects at the end

configurations.all {
    resolutionStrategy {
        force 'com.facebook.react:react-native:0.66.3'
    }
}

Thank you for making me waste 2 fucking days

Hello All,

I am using react native version 0.63.0 and getting the below error :

.gradle/caches/transforms-2/files-2.1/fbb7a340b18cb1ab123bd8116e2b4a16/core-1.7.0/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

see Fix for older react-native (< 0.63) section

After upgrading from 0.63.0 to 0.63.5 I am now getting similar transform errors for react-native dependencies when using react-native run-android.

Example here:

Execution failed for task ':react-native-config:generateDebugRFile'.
> Could not resolve all files for configuration ':react-native-config:debugRuntimeClasspath'.
   > Failed to transform react-native-0.63.5.aar (com.facebook.react:react-native:0.63.5) to match attributes {artifactType=android-symbol-with-package-name, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.

Have also tried the allprojects fix. Any ideas?

ext {
    buildToolsVersion = "29.0.2"
    minSdkVersion = 24
    compileSdkVersion = 29
    targetSdkVersion = 29
    supportLibVersion = "28.0.0"
}
buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://www.jitpack.io' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

gradlew version: Gradle 6.9.1

try to write this. kotlinVersion = “1.6.0”

ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        supportLibVersion = "28.0.0"
        kotlinVersion = "1.6.0"
    }

Hope this Method 1 will help in android build issue: https://stackoverflow.com/a/74334163/6786766

It’s working for me


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

Replace this in android/build.gradle file

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

       // ... your repository definitions

    }
}

After using the fix,The error dissapeared but when I build a release App, the build’s succesful but it keeps crashing as soon as it is getting installed. Is there a solution for that please ?

Description

Hey all, I’d like to share an update on a series of build failures React Native & Expo users have been experiencing when building Android apps starting from November 4th 2022.

We’d like to apologize for the disruption this caused to your developer workflows. The React team is fully committed to delivering a smooth developer experience, and we take this type of issues extremely seriously.

📢 Patches for >= 0.63

We have prepared releases for all the main versions of react-native with an hotfix:

🛳 0.70.5: https://github.com/facebook/react-native/releases/tag/v0.70.5 🛳️ 0.69.7: https://github.com/facebook/react-native/releases/tag/v0.69.7 🛳 0.68.5: https://github.com/facebook/react-native/releases/tag/v0.68.5 🛳️ 0.67.5: https://github.com/facebook/react-native/releases/tag/v0.67.5 🛳️ 0.66.5: https://github.com/facebook/react-native/releases/tag/v0.66.5 🛳️ 0.65.3: https://github.com/facebook/react-native/releases/tag/v0.65.3 🛳️ 0.64.4: https://github.com/facebook/react-native/releases/tag/v0.64.4 🛳️ 0.63.5: https://github.com/facebook/react-native/releases/tag/v0.63.5

By updating to these patch versions, your Android build should start working again.

To do so, in your package.json change react-native’s version to the relevant new patch (ex. if you are on 0.64.3, change to 0.64.4) and run yarn install. No other changes should be necessary, but you might want to clean your android artifacts with a cd android && ./gradlew clean before trying to re-run your Android app.

Fix for older react-native (< 0.63)

The fix above only works on gradle 6.2 and higher. Older react-native used older gradle.

You may determine your gradle version by looking in your /android/gradle/wrapper/gradle-wrapper.properties file.

If you are on an older version of react-native (for example 0.63 or earlier) that uses gradle version 6.1 or below, you must use a different workaround as gradle 6.1 does not support exclusiveContent.

Add this in the allprojects area of your android/buld.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())

allprojects {
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.65+, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }

Instead of using exclusiveContent, the hotfix must force the version of React Native. The recommended hotfix shells out to node to read your current version of react-native. If you hard code the version of react-native, when you upgrade your project in the future, your build will fail if you forget to remove this hotfix.

Note that this fix is fragile as the location of your package.json could be different if you are in a monorepo, and node might not be available if you use a node package manager like nvm.

Thank you @mikehardy for finding and providing this fix in your comment.

Technical Details

The issue

On November 4th 2022 we published the React Native version 0.71.0-rc0, the first release candidate for the 71 release series, on several public repositories. Specifically, this version was also published on Maven Central as we’re updating our artifacts distribution strategy (technical details are explained below).

This event resulted in build failures for Android on several users as they ended up downloading the wrong React Native version (0.71.0-rc0 instead of the version they were using in their project, say 0.68.0).

The build error looks something like this:

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'My Project'.
Could not determine the dependencies of null.
Could not resolve all task dependencies for configuration ':classpath'.
    > Could not resolve com.facebook.react:react-native:+.
      Required by:
          project :
    > No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found. 
      The consumer was configured to find a runtime of a library compatible with Java 11, 
      packaged as a jar, and its dependencies declared externally, as well 
      as attribute 'org.gradle.plugin.api-version' with value '7.3.3' but:

Sadly, due to how older projects of React Native were created in the past, we couldn’t simply re-publish older versions, and we’re asking users to update their template using the fix suggested below.

Why this happened

Historically, the React Native template provided build.gradle files that contain a dependency on the React Native Android library as follows: implementation("com.facebook.react:react-native:+").

Specifically, the + part of this dependency declaration is causing Gradle to pick the highest version among all the declared repositories (often referred as Gradle Dynamic versions). Till React Native version 0.70, we were shipping a Maven Repository inside the NPM package (inside the ./android folder). Starting from 0.71, we moved such folder and uploaded it to Maven Central.

Using Gradle Dynamic versions (i.e. a + dependency) is considered an antipattern (see the various warnings and notes on this page), specifically as it can lead to scenarios like this one and generally exposes users to less-reproducible builds. This is exactly what happened in this scenario, as builds started failing without any changes to user projects.

In 0.71 we cleaned up the new app template and removed all the + dependencies (see here) and we moved the template to use the React Native Gradle Plugin, which will allow us to prevent scenarios like this from happening in the future.

Sadly, users on older versions, say 0.66.0, were still using a + version. This caused their build to query all the repositories for the highest available versions of the React Native. While the node_modules/react-native/android folder contained a valid 0.66.0 version, Gradle honoured the + version and fetched version 0.71.0-rc0 from Maven Central as it’s higher from the semantic versioning ordering.

The resolutionStrategy block in the fix is forcing the version of com.facebook.react:react-native to all the projects to the one provided by the version of React Native you’re effectively using.

Who is affected?

All the React Native users on versions till 0.66.x are affected.

React Native users on versions from 0.67 till 0.70 could be affected, based on which third-party library they’re using.

We verified that empty projects created on versions from 0.67 till 0.70 are not affected.

However, some of your dependencies might end up causing a wrong resolution of the React Native Android library, resulting in build failures. For instance, we verified that a project on React Native 0.68.4 works well with Reanimated 2.12.0 but fails with Reanimated 2.10.0.

We also worked with Expo to make sure that users on eas build received the aforementioned fix, so those users should not be affected.

Why React Native Android was published on Maven Central?

As mentioned, this was done as part of the implementation of the RFC #580.

The summary of that RFC is to allow us to overcome the limitation of NPM in terms of package size. Moving to Maven Central will allow us to reduce the build time for our users and distribute more granular artifacts which will end up benefitting the overall developer experience. We’ll be able to share information on this in the near future.

In the initial Github Issue, several users suggest to remove the publishing from Maven Central or re-publish older artifacts to overcome the build failure without requesting a fix.

This is sadly not an option as:

  1. Maven Central is an immutable artifacts storage and doesn’t allow deletion.
  2. The publishing on 0.71.0-rc0 was effectively correct. We believe this episode is essentially a “mis-configuration” in user projects, and we believe the better solution is to distribute this fix to our users.

How could this have been prevented

We were already aware of the risk of having Gradle dynamic dependencies, so since React Native 0.67 we introduced an exclude rule on the Maven Central dependency inside the default template (see here for more context):

        mavenCentral {
            content {
                excludeGroup("com.facebook.react")
            }
        }

React Native used to be published on Maven Central till version 0.20.1 (published in 2016). We had users in the past accidentally fetching older versions of React from Maven Central, causing their build to fail.

This exclude directive assured that you won’t ever download React Native from Maven Central. However, third party libraries could declare repositories inside their repositories{} block which might not contain the exclude directive, resulting in potentially broken dependency resolution.

React Native version 0.71.0 will ship with an updated template that relies on React Native Gradle Plugin. This new integration will allow us to protect us against future distributed build failures like this one, by allowing to re-distribute updated build logic across the whole ecosystem if needed (this should protect us also against similar outages like the JCenter outage happened last year).

I’d like to thank everyone for your patience and understanding and I’d like to call out some members our our community, specifically @mikehardy, @Titozzz, @brentvatne, @inckie and all the other folks involved in the initial investigation and fix for this issue.

We’ll follow up with more updates in the future if needed.

Nicola On behalf of the React team

Thank you for sharing the update, it helped me to resolve the latest building errors😀

hope this help

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

Solution Reference

Anyone still having issues with DSO not being loaded (if using hermes), try this:

Change:

implementation("com.facebook.react:hermes-engine:+") { // From node_modules
    exclude group:'com.facebook.fbjni'
}

to:

implementation("com.facebook.react:hermes-engine:" + <YOUR_REACT_NATIVE_VERSION>) { // From node_modules
    exclude group:'com.facebook.fbjni'
}

for example, for mine I used:

implementation("com.facebook.react:hermes-engine:0.69.5") { // From node_modules
    exclude group:'com.facebook.fbjni'
}

Hi, I am facing an issue, while generating a build. .gradle/caches/transforms-2/files-2.1/e4fbec57f89d7c92a4c08621897ece3f/core-1.7.0/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

@kildip

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':react-native-webview:compileDebugKotlin'.
Compilation error. See log for more details
I am facing issue you please help me regarding on this

I had same problem - try to bump this lib version

I fixed it! with added this on (android/build.gradle) -

** exclusiveContent { filter { includeGroup “com.facebook.react” } forRepository { maven { url “$rootDir/…/node_modules/react-native/android” } } }** this code under allProject{ repositories { …here…}}

and updated gradle version on (android/gradle/wrapper/gradle-wrapper.properties) distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip

Hey, I’m having some issues when upgrading from react-native v0.64.1 -> v0.64.4. This is the error message I am getting when trying to create a build or running ./gradlew clean in the android directory. Gradle version 7.0.2. Any help is appreciated.

**************************

FAILURE: Build failed with an exception.

* Where:
Script '~/node_modules/react-native/react.gradle' line: 360

* What went wrong:
A problem occurred evaluating script.
> Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.

@tukaAlalami

@enzocardeal what is your ‘kotlinVersion’ , ‘targetSdkVersion’, and ‘compileSdkVersion’ ? can you please share your android/build.gradle with me ?

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        kotlinVersion = "1.5.31"
        RNNKotlinVersion = kotlinVersion
        buildToolsVersion = "30.0.2"
        minSdkVersion = 23
        compileSdkVersion = 31
        targetSdkVersion = 32
        ndkVersion = "21.4.7075529"
        androidXCore = "1.7.0"
        googlePlayServicesVersion = "17.0.0"
    }
    repositories {
        google()
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
        classpath("com.android.tools.build:gradle:4.2.2")
        classpath("com.google.gms:google-services:4.3.10")
        classpath("com.google.firebase:firebase-crashlytics-gradle:2.8.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        maven {
            // All of Detox' artifacts are provided via the npm module
            url "$rootDir/../node_modules/detox/Detox-android"
        }
        maven { url 'https://www.jitpack.io' }
    }
}

Has anyone here who are having this build failed issue tried to build signed bundle/apk for android? Because the solutions here react-native/issues/35210 and (expo/expo@02fb0a9), it makes the build for android successful on emulator and on real device. But my signed bundle/apk is crashing as soon as it’s downloaded and opened. I’m on RN 0.66 and I’ve tried gradle 6.9.0, 7.0.1 and 7.2.1 and my signed bundle is still crashing with no error messages shown.

Is there a reason why 0.68.5 has contents.xcworkspacedata removed from iOS? The Xcode doesn’t open the project correctly after removing this file.

react-native-community.github.io/upgrade-helper/?from=0.68.4&to=0.68.5

@Aleksefo thanks for pointing it out, it’s not intended. It’s probably a side effect of the pipeline generating the diff - the only change you should have to handle is the bump of the version. I’ll look into manually patching the rn-diff-purge repo that feeds the data to upgrade-helper to remove that unwanted change.

After upgrade react-native from 0.63.2 to 0.63.5, things are OK in Android but can not run in IOS.

Error:

Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Could not load NIB in bundle: ‘NSBundle </Users/lavinhquang/Library/Developer/CoreSimulator/Devices/A94B947B-CCB8-4075-A854-DE1F05B8E3DC/data/Containers/Bundle/Application/BA8FA348-126C-4E93-A0B5-847595703053/D4UPatient.app> (loaded)’ with name ‘LaunchScreen’’

I find a way to solve this build problem and no need to update to the hotfix RN version. I test the RN 0.64.2 is ok

just add these lines into the android/build.gradle file. note don`t delete other content for allproject in build.gradle

`allprojects {

    afterEvaluate {
        configurations.all {
            resolutionStrategy {
                force "com.facebook.react:react-native:0.64.+"
                force "com.facebook.react:hermes-engine:0.64.+"
            }
        }
    }

}`

updated from 0.66.2 to 0.66.5, still facing the same issue

Duplicate class com.facebook.hermes.BuildConfig found in modules jetified-hermes-debug-runtime (hermes-debug.aar) and jetified-hermes-release-runtime (hermes-release.aar)

Made it work without upgrading react-native version and by adding this in build.gradle, this works (hermes enabled or not, along with flipper too)

 exclusiveContent {
            // We get React Native's Android binaries exclusively through npm,
            // from a local Maven repo inside node_modules/react-native/.
            // (The use of exclusiveContent prevents looking elsewhere like Maven Central
            // and potentially getting a wrong version.)
            filter {
                includeGroup "com.facebook.react"
            }
            forRepository {
                maven {
                    url "$rootDir/../node_modules/react-native/android"
                }
            }
        }

final snippet looks like this

allprojects {
    repositories {
        exclusiveContent {
            // We get React Native's Android binaries exclusively through npm,
            // from a local Maven repo inside node_modules/react-native/.
            // (The use of exclusiveContent prevents looking elsewhere like Maven Central
            // and potentially getting a wrong version.)
            filter {
                includeGroup "com.facebook.react"
            }
            forRepository {
                maven {
                    url "$rootDir/../node_modules/react-native/android"
                }
            }
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")

gradle clean and rebuild after this fix.

For a project using react 17.0.2 and react-native 0.66 this fixed the build but our app kept crashing upon launch. Upgrading our gradle version from 7.4.1 to 7.5 in gradle-wrapper.properties fixed the issue.

After applying the patch the build succeeds but the app crashes on startup.

Here are some logs:

couldn't find DSO to load: libjscexecutor.so
SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.example./lib-main flags = 1]
SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~UK67LPhwA9CcaMFErm77fg==/com.example.-0ZyaFmhPROOzu1m39tXvFQ==/lib/arm64 flags = 0]
SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
Native lib dir: /data/app/~~UK67LPhwA9CcaMFErm77fg==/com.example.app-0ZyaFmhPROOzu1m39tXvFQ==/lib/arm64
result: 0

Does it happen to anyone else? I’m on 0.69.5.

My react-native version is 0.66.2 , same problem. I change package.json. “react-native”: “0.66.2”, to “react-native”: “0.66.5”, solve this problem.

Hallo guys any update for 0.64.2? how to fix this problem?

Please follow this link Hope it will work.

Jesus, 24 active working hours troubleshooting this. THANK GOD I FOUND THIS POST. THIS IS SOLVED NOW!!!

For old react-native versions on gradle 6.1 and below you need a different workaround:

@yuvital-render please take a look at https://github.com/facebook/react-native/issues/35210#issuecomment-1304536693

Thanks @cortinico everything is working fine. So once our projects updated to RN 0.71+ we must remove this workaround, right?

Thanks Alot RN team Finally my project is working i use this code

   configurations.all {
       resolutionStrategy {
           // Remove this override in 0.65+, as a proper fix is included in react-native itself.
           force "com.facebook.react:react-native:" + "0.67.3"
       }
    }

Prior to 4 November it was working fine and now when I am trying to build it by running yarn android but it is showing me. I tried the patch also 0.66.3 => 0.66.5 I cleaned the gradle Removed the node_modules

But I am getting this error everytime

/Users/dev/Desktop/Abc Projects/aargee/node_modules/react-native-webrtc/android/src/main/java/com/oney/WebRTCModule/VideoTrackAdapter.java:5: error: cannot access VideoFrame
import org.webrtc.VideoFrame;
                 ^
  bad class file: /Users/dev/.gradle/caches/transforms-2/files-2.1/8af035e80c335f19cef40762b46ee77a/jetified-libwebrtc.jar(org/webrtc/VideoFrame.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-webrtc:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

I have tried solution from My React Native was working fine upto 4 November but now throwing an exception while Running yarn android but no luck. Any help will be appreciated.

I have “react-native”: “^0.66.3”, “react-native-webrtc”: “^1.94.1”

I tried below solution as well

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())

allprojects {
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.65+, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }

Hey, I’m having some issues when upgrading from react-native v0.64.1 -> v0.64.4. This is the error message I am getting when trying to create a build or running ./gradlew clean in the android directory. Gradle version 7.0.2. Any help is appreciated.

**************************

FAILURE: Build failed with an exception.

* Where:
Script '~/node_modules/react-native/react.gradle' line: 360

* What went wrong:
A problem occurred evaluating script.
> Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.

Facing the same issue. updating from 0.64.2 to 0.64.4 and running ./gradlew clean yields this error

1: Task failed with an exception.
-----------
* Where:
Script '~/node_modules/react-native/react.gradle' line: 360

* What went wrong:
A problem occurred evaluating script.
> Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.


gradlew version = 7.0.2

        mavenCentral {
            content {
                excludeGroup("com.facebook.react")
            }
        }

This did not work for me (got other errors instead) with “react-native”: “0.66.4”, But what worked was this

allprojects {
    repositories {
       exclusiveContent {
           // We get React Native's Android binaries exclusively through npm,
           // from a local Maven repo inside node_modules/react-native/.
           // (The use of exclusiveContent prevents looking elsewhere like Maven Central
           // and potentially getting a wrong version.)
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }
        // ...
    ```

After upgrading from 0.68.0 to 0.68.5 I am now getting similar transform errors for react-native firbase dependencies when using react-native run-android. build sucessful gradle 7.3.3

Example here: `Execution failed for task ‘:app:mergeDebugAssets’.

Could not resolve all files for configuration ‘:app:debugRuntimeClasspath’. Failed to transform firebase-messaging-23.0.8.aar (com.google.firebase:firebase-messaging:23.0.8) to match attributes {artifactType=android-assets, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}. Could not find firebase-messaging-23.0.8.aar (com.google.firebase:firebase-messaging:23.0.8). Searched in the following locations: https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-messaging/23.0.8/firebase-messaging-23.0.8.aar Failed to transform firebase-datatransport-18.1.6.aar (com.google.firebase:firebase-datatransport:18.1.6) to match attributes {artifactType=android-assets, org.gradle.status=release}. Could not find firebase-datatransport-18.1.6.aar (com.google.firebase:firebase-datatransport:18.1.6). Searched in the following locations: https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-datatransport/18.1.6/firebase-datatransport-18.1.6.aar`

buildscript { ext { buildToolsVersion = “31.0.0” minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31 ndkVersion = “21.4.7075529” useMapLibre = true useCustomMapbox = false

  RNMapboxMapsImpl = "mapbox"

/// repositories { google() mavenCentral() jcenter()

}
dependencies {
    classpath("com.android.tools.build:gradle:7.0.4")
    classpath 'com.google.gms:google-services:4.3.10'
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("de.undercouch:gradle-download-task:4.1.2")
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {

repositories {
    google()
    jcenter()
    mavenLocal()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url("$rootDir/../node_modules/react-native/android")
    }
    maven {
        // Android JSC is installed from npm
        url("$rootDir/../node_modules/jsc-android/dist")
    }
    mavenCentral {
        // We don't want to fetch react-native from Maven Central as there are
        // older versions over there.
        content {
            excludeGroup "com.facebook.react"
        }
    }

App is getting crashed as soon as it is getting installed

This is probably obvious, but after implementing the patch and running ./gradlew clean, I needed to delete my node_modules folder and run npm install again - that got it working for me.

I’m running Expo Bare and prior to removing the node_modules folder, I was getting errors in the expo packages that seemed like they were looking for the previous RN version I was on (68.2) before upgrading to the patch (68.5).

getting error after updating patch from 0.66.4 to 0.66.5. Now whenever I make a build, I get error in different libraries/ modules like Error: Unable to resolve module ./arrayWithHoles.js from D:\stylon\node_modules\@babel\runtime\helpers\slicedToArray.js: error: Error: While trying to resolve module react-isfrom fileD:\stylon\node_modules\prop-types\index.js` sometime in 3rd party libs, stating they don’t exist while they do

Given that our project was at 0.64.2. Upgrading to the patch ( 0.64.4 ) resulted in errors from React-native-svg. However the recommended maven exclusion works. Any clue? 🤔

@BhanaviShukla I faced same issue after version increasing and resolved by ./gradlew clean

which version of React-native-svg you are using trying to upgrade to latest version

i have the same error Execution failed for task ‘:react-native-navigation:compileReactNative63DebugKotlin’. after i upgrade from react native .0.67.2 to 0.67.5 any help ?

finally, it worked for me!

I have a question when I updated react native version from 0.66.4 to 0.66.5 in development env and AOS build success, Is it okay use code push to 0.66.4 version production ? I’m afraid it’s going to conflict.

@jforaker I agree with @pascale-m and would personally suggest using NPM.

I have upgraded my RN version to 0.68.5, but keep getting the following issue:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':@react-native-community_async-storage:verifyReleaseResources'.
> Could not resolve all task dependencies for configuration ':@react-native-community_async-storage:releaseRuntimeClasspath'.
   > Could not resolve com.facebook.react:react-native:0.68.+.
     Required by:
         project :@react-native-community_async-storage
      > Failed to list versions for com.facebook.react:react-native.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml.
            > Could not GET 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'. Received status code 502 from server: Bad Gatewa

is there a specific need to use yarn? or would npm be equivalent?

Applying the allProjects force solution worked for us, preventing the need to merge the hotfix and release our react-native fork. it’s a combination of some of the solutions above as we also ran into the Hermes issue on release builds. Thanks to @Nesh108 and others 🙇

allprojects {
    configurations.all {
        resolutionStrategy {

            // Manually set the react-native version to resolve this upstream issue: https://github.com/facebook/react-native/issues/35210
            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())
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
            force "com.facebook.react:hermes-engine:" + REACT_NATIVE_VERSION
        }
    }
    ...
}

Hi, I am still not able to fix the build after installing patch version of react-native: 0.63.5. When I upgrade it to the 0.63.5 - I am getting this errors:

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find any version that matches com.facebook.react:react-native:0.63.+.
Versions that do not match:
  - 0.62.2
  - 0.71.0-rc.0
  - 0.20.1
  - 0.20.0
  - 0.19.1
  - + 14 more
Required by:
    project :app
    project :app > project :react-native-community_viewpager
* Get more help at https://help.gradle.org/

my react-native info ouput here:

System:
    OS: macOS 13.0
    CPU: (8) x64 Apple M1
    Memory: 33.76 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 8.9.0 - ~/.nvm/versions/node/v14.19.0/bin/npm
    Watchman: 2022.09.26.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 16.0.1 - /usr/bin/javac
    Python: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: 0.63.5 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

I would really appreciate your help ❤️ Thank you

@baierjak did you accidentally type a “+” in your package.json?

@davidjonesdialexa Nope, thats directly in the react.gradle file - includes in the new patch version (0.63.5) which is recommended to update from 0.63.4 if I understood it corectly 😃 But after install this React version cannot be found 😦(

image

Hi, I am still not able to fix the build after installing patch version of react-native: 0.63.5. When I upgrade it to the 0.63.5 - I am getting this errors:

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find any version that matches com.facebook.react:react-native:0.63.+.
Versions that do not match:
  - 0.62.2
  - 0.71.0-rc.0
  - 0.20.1
  - 0.20.0
  - 0.19.1
  - + 14 more
Required by:
    project :app
    project :app > project :react-native-community_viewpager
* Get more help at https://help.gradle.org/

my react-native info ouput here:

System:
    OS: macOS 13.0
    CPU: (8) x64 Apple M1
    Memory: 33.76 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 8.9.0 - ~/.nvm/versions/node/v14.19.0/bin/npm
    Watchman: 2022.09.26.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 16.0.1 - /usr/bin/javac
    Python: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: 0.63.5 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

I would really appreciate your help ❤️ Thank you

@baierjak did you accidentally type a “+” in your package.json?

I just want to point out some people might be getting this error instead of the one you guys have reported in the instructions. Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library [com.facebook.react:react-native:0.71.0-rc.0]

image

This too will be fixed by upgrading to your respective react-native patch.

Worked for 0.66.4 -> 0.66.5

Excuse me, but how can i install this patch https://github.com/facebook/react-native/releases/tag/v0.64.4 ?

In your package.json change react-native version to 0.64.4 and run yarn install

@ivanhoe-dev Hey. I saw your comment and I had similar error while building android this whole day. As you mentioned to follow the instruction for the hotfix, I have downloaded the zip (version 0.66.5) which included bunch of files. I have no idea how to fix my project with the official zip. Could you share how to do it~? Thanks a lot.

> Task :bugsnag_react-native:compileDebugKotlin FAILED
.... Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.16.

@gabpaet that’s unrelated, it appears you need to bump your minCompileSdk to 33 for unrelated reasons. Note this also transitively implies a bump of JDK to 11

I faced this issue on Saturday. FYI, I used rn v0.67.4. When I tried to run android on my local machine, it was failed. the error message indicated on @react-native-async-storage/@async-storage. I did clean my project gradle was no luck. However, on my Jenkins pipeline this issue did not occur. So, I concluded there is global caches somewhere in my machine. After googling it i found this rm -rf $HOME/.gradle/caches. Solved the issue 🎉

Do not post “me too” comments

This issue affects nearly everyone and github issues do not handle enormous numbers of comments well.

If you post metoo comments (or even "thank you"s) you are actively making it harder on your fellow developers to fix their builds by making it harder for them to find the relevant information.

If it works for you please share the solution with developers you know or retweet https://twitter.com/reactnative/status/1589296764678705155 - that will have a positive impact for other developers

It appears there may be a problem related to people not using hermes, though this has not been confirmed.

It is still our understanding that if applied correctly, we have these choices for a fix:

1- for the actual 0.71.0-rc.0 version you do not need a workaround 2- for “current” (react-native 0.64+ or 0.65, using gradle 6.2 or higher as determined in your gradle wrapper) - adding the exclusive repository definition described all the way at the top in the main description above works 3- for “old” (react-native 0.63 or lower, using gradle 6.1 or lower) - pinning the version via this workaround works https://github.com/facebook/react-native/issues/35210#issuecomment-1304536693

Hi, after applying the fix the build in eas works correctly, but when running the application in production in android it crashes at startup. Does it happen to anyone else? any solution?