3

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.

enter image description here

3 Answers3

8

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
Boken
  • 3,207
  • 9
  • 25
  • 31
Javad Dehban
  • 1,118
  • 3
  • 7
  • 19
1

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's a link to the JDK download: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

Druckles
  • 2,273
  • 2
  • 34
  • 52
Scott
  • 31
  • 4
-1

upgrade java jdk then go to

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

to the latest JDK

Boken
  • 3,207
  • 9
  • 25
  • 31
Hossam
  • 1
  • 1