ayanonize
ayanonize

Reputation: 215

npx react-native run-android error > Task :react-native-gradle-plugin:compileKotlin FAILED

by running command npx react-native run-android or npm run android it gives the following error if you know why is this happening please let me know

> [email protected] android
> react-native run-android

info Starting JS server...
info Installing the app...
> Task :react-native-gradle-plugin:compileKotlin FAILED
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 10s

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 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 10s

    at makeError (/Users/ayan/Documents/myApp/node_modules/execa/index.js:174:9)
    at /Users/ayan/Documents/myApp/node_modules/execa/index.js:278:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runOnAllDevices (/Users/ayan/Documents/myApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/ayan/Documents/myApp/node_modules/@react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.

if you know the answer please let me know thank you in advance

Upvotes: 1

Views: 6989

Answers (4)

聂云恩
聂云恩

Reputation: 1

I have the same problem.

The reason is my JAVA_HOME environment variable is set to xxxx/java/jre1.8xx;

Change to your path/jdk-11; Just running

I hope it will help you

------Note this error message:

"Kotlin could not find the required JDK tools in the Java installation."

Upvotes: 0

Vishvas Patel
Vishvas Patel

Reputation: 88

Run the following command

chmod 755 android/gradlew

inside your app root folder then run

react-native run-android

Upvotes: 1

Akshay PandherPatte
Akshay PandherPatte

Reputation: 173

Try to run this command:-

ANDROID_HOME=~/Library/Android/sdk

and after that

npx react-native run-android

Or else try to update the gradle version by putting this line into the wrapper properties

distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip

Upvotes: 1

Engr.Aftab Ufaq
Engr.Aftab Ufaq

Reputation: 6344

there is issue with your java installation. Please Install JDK 11 on your machine. you can install mac with HomeBrew and on windows use can use chocolatey

check this message so you can identify this issue Make sure Kotlin compilation is running on a JDK, not JRE.

Upvotes: 1

Related Questions