Flutter error Kotlin could not find the required JDK tools

18,032

Solution 1

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

Solution 2

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

Share:
18,032
Admin
Author by

Admin

Updated on June 18, 2022

Comments

  • Admin
    Admin almost 2 years

    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