简体   繁体   English

Gradle 检测到 Java 1.8 而不是 Java 11

[英]Gradle detects Java 1.8 instead of Java 11

When creating a new project with当创建一个新项目时

npx react-native init newProject

and start the app by并通过以下方式启动应用程序

npx react-native run-android

I will receive this error:我会收到这个错误:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\path\newProject\android\app\build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     Your current JDK is located in  C:\Program Files\OpenJDK\openjdk-8u292-b10\jre
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

* 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 11s

error Failed to install the app. Make sure you have the Android development environment set u
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

./gradlew --version ./gradlew --version

------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------

Build time:   2022-08-05 21:17:56 UTC
Revision:     d1daa0cbf1a0103000b71484e1dbfe096e095918

Kotlin:       1.6.21
Groovy:       3.0.10
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          1.8.0_292 (Oracle Corporation 25.292-b10)
OS:           Windows 10 10.0 amd64

I have tried it with other gradle versions and other react native versions, but the error still persists.我已经尝试过其他 gradle 版本和其他 react native 版本,但错误仍然存在。 Existing projects are working...现有项目正在运行...

You need to install Java 11 on your system and update the JAVA_HOME and PATH variables on your system.您需要在系统上安装 Java 11 并更新系统上的JAVA_HOMEPATH变量。 If you are using Windows, you can add or update it under environment variables.如果您使用的是 Windows,您可以在环境变量下添加或更新它。 For Linux-based systems, you can just add these commands to to your profile file:对于基于 Linux 的系统,您只需将这些命令添加到您的配置文件中:

export JAVA_HOME="java11path"

export PATH=$JAVA_HOME/bin:$PATH

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Java 11 而不是 1.8,xsl-fo 转换要慢得多 - xsl-fo transformation much slower with Java 11 instead of 1.8 并行流() java 1.8 与 11 - parallelStream() java 1.8 vs 11 Android Gradle 插件需要 Java 11 才能运行。 您当前使用的是 Java 1.8。 错误 - Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. Error Android Gradle 插件需要 Java 11 才能运行。 您当前使用的是 Java 1.8。 反应原生 - Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. React Native Android Gradle 插件需要 Java 11 才能运行。 您目前正在使用 Java 1.8 - React Native - Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8 - React Native Azure 构建错误:“Android Gradle 插件需要 Java 11 才能运行。您当前使用的是 Java 1.8” - Azure build error: "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8" Android Gradle 插件需要 Java 11 才能运行。 您当前使用的是 Java 1.8 - Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8 gradle 无法定位平台:'Java SE 11' 使用工具链:'JDK 8 (1.8)' - gradle Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)' Java+Gradle 构建卡在 JDK 11+ 的 compileTestJava 阶段,但在 JDK 1.8 上工作正常,控制台没有错误 - Java+Gradle build stucks on compileTestJava stage on JDK 11+, but works fine on JDK 1.8, no errors in console Gradle for Java 11 with Modules - Gradle for Java 11 with Modules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM