21

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

12 Answers 12

18

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

Sign up to request clarification or add additional context in comments.

6 Comments

Thank you! You led me in the right direction, I had kotlin_version instead of kotlinVersion in my build.gradle :)
There is no kotlinVersion or kotlin_version in android/build.gradle
already using 1.6.0 . Still facing this issue.
I'm facing the same issue with 1.8.0
i'm facing same issue with 1.9.31
|
14

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

1 Comment

How can we find compatible version of screens . im using react-navigation @5.x
12

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

Comments

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

Comments

2

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

Comments

1

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

Comments

1

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.+"

1 Comment

now react native is on 0.73 and there must be some new way to fix it. do you have any idea about this is in newer versions
1

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"

2 Comments

I'm using react-native 0.72.5 and that property is not set in my gradle.properties but still having issues :(
is your kotlin version ok?
1

Same issue in expo managed app.I solved it by doing this Just upgraded react-native-screens version from 3.18.2 to 3.25.0 and it works.

Comments

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

Comments

0

I had the same issue and tried all the abovementioned solutions, but none worked.

In the end, what worked for me was removing the react-native-screens package completely and then reinstalling it with a specific version 3.27.0:

Step1- npm uninstall react-native-screens

Step2- npm install [email protected]

Comments

-1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.