Flutter错误:Kotlin无法找到所需的JDK工具。

huangapple go评论89阅读模式
英文:

Flutter error Kotlin could not find the required JDK tools

问题

I first created a new flutter project.

But I got this error:

  • What went wrong:
    Execution failed for task ':app:compileDebugKotlin'.
    Kotlin could not find the required JDK tools in the Java installation 'C:\Program Files\Java\jre1.8.0_261' used by Gradle. Make sure Gradle 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 33s
Exception: Gradle task assembleDebug failed with exit code 1

I also tried this method, but it didn't work.

Flutter错误:Kotlin无法找到所需的JDK工具。

英文:

I first created a new flutter project.

But I got this error:

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation 'C:\Program Files\Java\jre1.8.0_261' used by Gradle. Make sure Gradle 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 33s
Exception: Gradle task assembleDebug failed with exit code 1

I also tried this method, but it didn't work.

Flutter错误:Kotlin无法找到所需的JDK工具。

答案1

得分: 17

第一步:

我将以下行添加到gradle.properties文件中

org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_261 你的jdk版本

第二步:

将以下行添加到gradle-wrapper.properties文件中

至地址 => \flutter_app\android\gradle\wrapper\gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
英文:

Step1:

I added the following line to the gradle.properties file

org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_261 your jdk version

Step2:

add the following line to gradle-wrapper.properties file

to the address => \flutter_app\android\gradle\wrapper\gradle-wrapper.properties

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

答案2

得分: 5

我在我的JRE更新后遇到了这个错误,但我的JDK没有更新。在我下载并安装了更新的JDK之后,错误消失了。

这是JDK下载链接:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

英文:

I got this error when my JRE updated, but my JDK didn't. After I downloaded and installed the updated JDK, the error went away.

Here is a link to the JDK download: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

答案3

得分: 0

以下是翻译好的内容:

这两种方法中的一种应该对您有帮助:

  1. 在位于您的 HOME_DIRECTORY.gradle 目录中的 gradle.properties 文件中,设置 org.gradle.java.home=/path_to_jdk_directory

或者:

  1. 在您的 build.gradle 文件中:
compileJava.options.fork = true
compileJava.options.forkOptions.executable = '/path_to_javac'

答案来源

英文:

One of these two methods should help you:

  1. In gradle.properties in the .gradle directory in your HOME_DIRECTORY set org.gradle.java.home=/path_to_jdk_directory

OR:

  1. In your build.gradle
compileJava.options.fork = true
compileJava.options.forkOptions.executable = '/path_to_javac'

answer taken from here

答案4

得分: 0

以下是翻译好的内容:

简单解决方案,解决了我的问题:
1)只需转到Flutter项目中的项目Android文件夹。
2)打开gradle.properties文件并添加以下行 ==>
org.gradle.java.home=C:\Program Files\Java\jdk-13.0

C:\Program Files\Java\jdk-13.0 - 这是您PC上的JDK位置,请检查是否未安装JDK,如果未安装JDK,请先安装JDK并提供特定的JDK位置。谢谢

英文:

Simple solution to this what my issue resolved

  1. Just go to your project Android folder in flutter project
  2. Open gradle.properties File and add line ==>
    org.gradle.java.home=C:\Program Files\Java\jdk-13.0

C:\Program Files\Java\jdk-13.0 - This is Your JDK location in your PC Please check if JDK not installed then first install JDK and provide specific JDK location . Thanks

答案5

得分: -2

升级 Java JDK,然后按以下步骤操作:

文件 -> 项目结构 -> 项目设置 -> 项目更改“项目 SDK”

到最新的 JDK。

英文:

upgrade java jdk then go to

file -> project structure -> project setting -> project change "project sdk"

to the latest JDK

huangapple
  • 本文由 发表于 2020年7月31日 00:41:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/63177661.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定