英文:
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.
英文:
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.
答案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
以下是翻译好的内容:
这两种方法中的一种应该对您有帮助:
- 在位于您的
HOME_DIRECTORY
的.gradle
目录中的gradle.properties
文件中,设置org.gradle.java.home=/path_to_jdk_directory
。
或者:
- 在您的
build.gradle
文件中:
compileJava.options.fork = true
compileJava.options.forkOptions.executable = '/path_to_javac'
英文:
One of these two methods should help you:
- In
gradle.properties
in the.gradle
directory in yourHOME_DIRECTORY
setorg.gradle.java.home=/path_to_jdk_directory
OR:
- In your
build.gradle
compileJava.options.fork = true
compileJava.options.forkOptions.executable = '/path_to_javac'
答案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
- Just go to your project Android folder in flutter project
- 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论