简体   繁体   中英

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

> myApp@0.0.1 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

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.

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

Run the following command

chmod 755 android/gradlew

inside your app root folder then run

react-native run-android

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM