npx react-native运行-android错误>任务:react-native-gradle插件:编译Kotlin失败

cgfeq70w  于 2023-01-14  发布在  React
关注(0)|答案(3)|浏览(501)

通过运行命令npx react-native run-android或npm run android它给出以下错误如果你知道为什么发生这种情况请让我知道

> 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.

如果你知道答案,请让我知道,谢谢

9rygscc1

9rygscc11#

尝试运行此命令:-
安卓系统_主页=~/图书馆/安卓系统/软件开发包
之后
npxReact-原生运行-安卓
或者尝试通过将此行放入 Package 器属性来更新gradle版本
分发网址=https:services.gradle.org/distributions/gradle-7.5.1-all.zip

sc4hvdpw

sc4hvdpw2#

运行以下命令
chmod 755安卓/格雷德卢
在应用程序根文件夹中,然后运行
react-native运行-android

8hhllhi2

8hhllhi23#

java安装有问题。请在您的计算机上安装JDK 11。您可以使用HomeBrew安装mac,在windows上可以使用chocolatey
请检查此消息,以便您可以识别此问题。请确保Kotlin编译是在JDK而不是JRE上运行的。

相关问题