14

I am trying to use React Navigation in my RN project, but when I install react-native-screens, which is a required package for it to work, I cannot build the project again.

The error I get is the following:

Task :react-native-screens:compileDebugKotlin FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

I have tried a few things I saw other people do, but nothing has worked so far.

Can you help me? Thanks

MIPB
  • 1,770
  • 2
  • 12
  • 21

9 Answers9

16

I changed my kotlin version to kotlinVersion = "1.5.31" in android/build.gradle

ahmed hassan
  • 232
  • 2
  • 4
12

If you facing this after adding @react-navigation/native@6.0.10 library to a project with react-native @0.69.0 just upgrade react-native-screens@3.14.0 this specific version

11

Update android/build.gradle as follows:

 {
 buildscript {
  ext {
      ...
     kotlinVersion = "1.5.31"
  }
 dependencies { 
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
    }
  }
}

Note : If this error comes back, Uninstall app from emulator and build again or Delete this emulator and create new one and try.

enter image description here

lakshan sampath
  • 161
  • 1
  • 7
11

In case you observe this issue after the 04th of November 2022, it might be related to the issue 35210:

Android build failures happening since Nov 4th 2022

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
mahmoudyy
  • 150
  • 1
  • 5
0

This is an issue after they released the React Native version 0.71.0-rc0. So pretty much all 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, depending on the npm packages they are using. To fix this, you can follow the instruction in this issue here: https://github.com/facebook/react-native/issues/35210

Steve Ton
  • 36
  • 6
0

Please update react-native to respective patch version mentioned in this ticket https://github.com/facebook/react-native/issues/35210

0

I have solved this issue by putting this chunk of code in the 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())

// I have placed above line just above allprojects{

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
        }
    }
...
}
راجہ مخلص
  • 1,177
  • 6
  • 15
0

If you are facing this issue on November 2022, maybe this solution can help you to fix it.

In android/build.gradle:

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

Change to the version of React Native that is used in your project.

(example: force "com.facebook.react:react-native:0.68.+"

0

I reduced the node version form 19 to 16.16.0. Go to the below link. https://nodejs.org/en/blog/release/v16.16.0

Since I am on macOS-64-bit. I downloaded:- macOS 64-bit Installer: https://nodejs.org/dist/v16.16.0/node-v16.16.0.pkg

Image shows different installer files based on OS and specs