info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 936 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...
> Task :react-native-gradle-plugin:compileKotlin FAILED
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version.
1 actionable task: 1 executed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-gradle-plugin:compileKotlin'.
> Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property 'compilerRunner$kotlin_gradle_plugin'.
> Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilation is running on a JDK, not JRE.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-gradle-plugin:compileKotlin'.
> Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property 'compilerRunner$kotlin_gradle_plugin'.
> Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilation is running on a JDK, not JRE.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
at makeError (C:UsersdhanpReact native projectstest3ProjectNamenode_modulesexecaindex.js:174:9)
at C:UsersdhanpReact native projectstest3ProjectNamenode_modulesexecaindex.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (C:UsersdhanpReact native projectstest3ProjectNamenode_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:109:5)
at async Command.handleAction (C:UsersdhanpReact native projectstest3ProjectNamenode_modules@react-native-communityclibuildindex.js:192:9)
info Run CLI with --verbose flag for more details
I have seen solutions which involve changing the classpath() and distribution URL, but I have already done it.
from my build.gradle file:
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:4.1.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
from gradle-wrapper
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-7.4.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
None of this fixes the error, additionally, i have noticed that running gradlew clean also provokes the same error
> Task :react-native-gradle-plugin:compileKotlin FAILED
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-gradle-plugin:compileKotlin'.
> Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property 'compilerRunner$kotlin_gradle_plugin'.
> Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilation is running on a JDK, not JRE.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
1 actionable task: 1 executed
I have also tried adding the following piece of code to the build.gradle file
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
}
kindly help me fix this, I used to use EXPO CLI previously and everything was working well, All of this happened in an attempt to learn the React-native CLI.
7
Answers
Found the solution, not sure why it works though
i used the following commands to start the build
now open another terminal and execute the following
instead of
and
where the latter is suggested by the official documentation
I am facing the same issue where All Java packages were installed or synced perfectly but kotlin packages were not synced it throws an error of kotlin compilation.
I install kotlin package on Android Studio by following This.
After that, you need to remove the cache of this project from
After that when your project is re-open and synced successfully then clean your project from
Build -> Clean Project
.After that, all packages of kotlin were installed perfectly.
I changed gradle version and solved it.
Reference
I just installed jdk11 then run cd ./android/ && ./gradlew clean That works for me
I had the same problem and to solve this problem I changed in gradle-wrapper.properties file
before:
after:
I hade the same issue using expo
I removed the
eas.json
file, aseas build
creates a neweas.json
fileIt worked for me.
I had the same problem and to solve this problem I did:
package.json
I prefixed the version with^
, thenyarn install
. (Updatereact native
version0.68.2
for^0.68.2
)Reference: https://github.com/facebook/react-native/issues/34410