react-native-screens:compileDebugKotlin FAILED

39.9k Views Asked by At

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

10

There are 10 best solutions below

4
On BEST ANSWER

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

0
On

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

0
On

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

0
On

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
On

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
On

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

1
On

If you facing this after adding @react-navigation/[email protected] library to a project with react-native @0.69.0 just upgrade [email protected] this specific version

0
On

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

0
On

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

0
On

For those who are using react-native: 0.72.5

Comment or remove android.nonTransitiveRClass=true from gradle.properties. This worked for me. nonTransitiveRClass set as true is causing the problem react-native-screens:compileDebugKotlin FAILED.

Versions:

"react-native": "0.72.5"
"react-native-screens": "3.25.0"
"react-native-reanimated": "^3.5.4"

android/build.gradle-> kotlinVersion

kotlinVersion = "1.6.21"