I installed react-native on my Mac (Ventura). React-native doctor doesn’t show any error and when I use npx react-native run-android I have a problem with gradle-plugin.
First I got this error:
Task :gradle-plugin:compileKotlin FAILED
I thought about a version problem with gradle. So I looked at the version
Here is my gradle --version
gradle --version
------------------------------------------------------------
Gradle 8.5
------------------------------------------------------------
Build time: 2023-11-29 14:08:57 UTC
Revision: 28aca86a7180baa17117e0e5ba01d8ea9feca598
Kotlin: 1.9.20
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 21.0.1 (Azul Systems, Inc. 21.0.1+12-LTS)
OS: Mac OS X 13.6.1 x86_64
So, I updated my build.gradle to this (force to 8.5, the installed version):
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.5") // Version de Gradle
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20" // Version de Kotlin
classpath("com.facebook.react:react-native-gradle-plugin")
}
}
I did the same here with gradle-wrapper.properties (=>8.5)
Please don’t confuse the version of Gradle with the version of the Android Gradle Plugin.
They unluckily named their artifact gradle, but it is the Android Gradle Plugin and of that no version 8.5 exists.
gradle-8.5-all/3zlzzgtsutfj0pbojr50n2l7z/gradle-8.5/lib/kotlin-stdlib-1.9.20.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
I understand (but not sure) kotlin uses 1.9.0 version but expected version is 1.7.1. Is this a problem with a gradle-plugin ? Which version of each may I use ?
As far as I understand that Kotlin compiler error is, that you are using Kotlin 1.7 but try to depend on Kotlin stdlib 1.9.20 from Gradle distribution. From the information you provided I have no answer how you ended up in that state.
Yes, I would say your React Native version, probably 0.72.x is not compatible with Gradle 8.
But you probably should ask in some React Native community or documentation about details.
Well, in the meantime, I started a new project and I discovered react-native has been updated. My new project is running under react native 0.73 in place of 0.72.7.
Surprising, in the new react, the gradle version is 8.3. I don’t know why I had the 8.5 before but well…
The new react native now requires yarm and JDK between 17 and 20. I had 21, so I installed the 17. Then my new project was successfull with react-native doctor. I was ready to try npx react-native run-android. But again, it failed to install app with ./gradlew app:installDebug
I made again a build scan for this project. I hope you could help me.
Unfortunately not.
I only can say that some provider that is tried to be resolved and has something to do with task dependencies and a file collection does not have a value.
But I cannot see where this is coming from.