react-native-screens:compileDebugKotlin FAILED
Asked Answered
T

11

18

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

Trioxide answered 24/6, 2022 at 23:44 Comment(0)
C
17

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

Cameraman answered 25/6, 2022 at 11:46 Comment(5)
Thank you! You led me in the right direction, I had kotlin_version instead of kotlinVersion in my build.gradle :)Trioxide
There is no kotlinVersion or kotlin_version in android/build.gradlePartan
already using 1.6.0 . Still facing this issue.Simplehearted
I'm facing the same issue with 1.8.0Leopoldeen
i'm facing same issue with 1.9.31Thrill
P
12

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

Parkland answered 6/7, 2022 at 11:14 Comment(1)
How can we find compatible version of screens . im using react-navigation @5.xSimplehearted
H
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

Haukom answered 20/7, 2022 at 6:34 Comment(0)
C
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

Castlereagh answered 7/11, 2022 at 15:45 Comment(0)
I
1

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

Isomerism answered 8/11, 2022 at 5:31 Comment(0)
D
1

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

Desquamate answered 8/11, 2022 at 6:13 Comment(0)
P
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.+"

Purge answered 6/12, 2022 at 12:55 Comment(1)
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 versionsDissimilar
D
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"
Denote answered 29/9, 2023 at 11:1 Comment(0)
H
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
        }
    }
...
}
Honeyed answered 10/11, 2022 at 7:3 Comment(0)
I
0

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.

Iniquitous answered 3/8 at 20:33 Comment(0)
P
-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

Pumpernickel answered 25/8, 2023 at 12:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.