skip to Main Content

While running react native app I am getting following error:

`

Task :app:mergeDebugNativeLibs FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use ‘–warning-mode all’ to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.2/userguide/command_line_interface.html#sec:command_line_warnings
574 actionable tasks: 2 executed, 572 up-to-date

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:mergeDebugNativeLibs’.

A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path ‘lib/armeabi-v7a/libfbjni.so’ from inputs:
– C:Usersnouman.gradlecachestransforms-36ef14503de3c85fa1ab2aba364d580cctransformedjetified-react-native-0.71.0-rc.0-debugjni
– C:Usersnouman.gradlecachestransforms-364faf76bb2f0142d731347d7bfff47d4transformedjetified-fbjni-0.3.0jni
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets

  • 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.

  • Get more help at https://help.gradle.org

BUILD FAILED in 32s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:mergeDebugNativeLibs’.

A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path ‘lib/armeabi-v7a/libfbjni.so’ from inputs:
– C:Usersnouman.gradlecachestransforms-36ef14503de3c85fa1ab2aba364d580cctransformedjetified-react-native-0.71.0-rc.0-debugjni
– C:Usersnouman.gradlecachestransforms-364faf76bb2f0142d731347d7bfff47d4transformedjetified-fbjni-0.3.0jni
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets

  • 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.

  • Get more help at https://help.gradle.org

BUILD FAILED in 32s

at makeError (D:BayQi-Customer-Mobile-Appnode_modulesexecaindex.js:174:9)
at D:BayQi-Customer-Mobile-Appnode_modulesexecaindex.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (D:BayQi-Customer-Mobile-Appnode_modulesreact-nativenode_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:94:5)
at async Command.handleAction (D:BayQi-Customer-Mobile-Appnode_modules@react-native-communityclibuildindex.js:192:9)

info Run CLI with –verbose flag for more details.
`

I am trying to run my react native app in physical device but getting this error.
It was running okay but suddenly has stopped working

7

Answers


  1. UPDATED ANSWER

    📢 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.

    Source https://github.com/facebook/react-native/issues/35210

    OLD ANSWER

    Add this to your android/build.gradle,

    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 {
                force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
            }
        }
    

    If that does not work for you (with the dynamic version), then hard code your version in:

    PLEASE BE CAREFUL TO MOVE THIS VERSION WHEN YOU UPDATE REACT-NATIVE

    allprojects {
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.react:react-native:<your version>'
            }
        }
        repositories {
        // ...
        }
    }
    

    Check this for more updates https://github.com/facebook/react-native/issues/35204

    Login or Signup to reply.
  2. // Top-level build file where you can add configuration options common to all sub-projects/modules

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        // ...
    }
    
    
    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"
    +               }
    +           }
    +       }
            // ...
        }
    }
    Login or Signup to reply.
  3. This helped me to resolve the issue.

    This is happening because all the templates reference the React Native dependency by range, like implementation com.facebook.react:react-native:+. Usually this dependency gets resolved from the local Maven repo in ./node_modules/react-native/android but, since it has been published to Maven Central, it’s now grabbing the very latest RC.

    You can resolve this problem by forcing the React Native dependency to the version you expect with something like this implementation com.facebook.react:react-native:0.68.2!! in your app’s Gradle file. The !! is shorthand for restricting Gradle from upgrading if your project or its transitive dependencies depend on a newer version. AFAIK Maven Central is immutable and the published dependency can’t removed so this might be the only solution.

    File: android/app/build.gradle
    dependencies {
        implementation 'com.facebook.react:react-native:0.67.2!!'
    }
    

    Reference: https://github.com/facebook/react-native/issues/35204

    Login or Signup to reply.
  4. Add following lines inside the android>build.gradle file –

    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"
               }
           }
       }
    }
    

    This issue occurred from November 4th 2022. See the reference: https://github.com/facebook/react-native/issues/35210

    Login or Signup to reply.
  5. Workaround: I have made the following changes & It is working:

    1. In gradle-wrapper.properties file, change gradle version
    distributionUrl=https://services.gradle.org/distributions/gradle-6.9-all.zip
    
    
    1. In project level build.gradle file, add following lines:
          dependencies {
                classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0")
             }
        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"
                  }
                }
              }
           }
    
        configurations.all {
                resolutionStrategy {
                  force 'androidx.core:core:1.6.0'
                  force 'androidx.core:core-ktx:1.6.0'
                }
            }
    
    1. In app level build.gradle, add these dependecies:
    implementation 'androidx.core:core-ktx:1.6.0',
    implementation 'androidx.core:core:1.6.0'
    
    Login or Signup to reply.
  6. add this to your app/build.gradle

    android {
       // yout existing code
       packagingOptions {
            pickFirst '**/libc++_shared.so'
            pickFirst '**/libfbjni.so'
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search