skip to Main Content

I have install Flutter and set up Android SDK. But know I am facing this issue.

FAILURE: Build failed with an exception.

* What went wrong:
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:Program FilesJavajdk-20binjava.exe

* 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
Exception: Gradle task assembleDebug failed with exit code 1

When I looked for the solutions online, all the videos gave the solution to delete jre folder in Android Studio. But I don’t have it and I use only VS Code. Please help me out with a step by step solution.enter image description here

2

Answers


  1. Check your environmental variables. You seem to have set the wrong path to your JAVA_HOME Variable. Try updating the path to your JDK root folder.

    1. Search ‘environmental variables’ on your start menu.
    2. Select ‘Edit the System Environmental Variables’.
    3. Under ‘System variables’, scroll to JAVA_HOME and edit the path to the path of your JDK e.g "C:Program FilesJavajdk-18" (Install this if you haven’t).
    4. Under ‘User variables’, scroll to Path and edit the path to the path of your JDK (Including the bin folder) e.g "C:Program FilesJavajdk-18bin".

    This should fix the issue

    Login or Signup to reply.
  2. Use the following settings in vscode to specify the jdk path.

    "java.configuration.runtimes": [
      {
        "name": "JavaSE-1.8",
        "path": "/usr/local/jdk1.8.0_201"
      },
      {
        "name": "JavaSE-11",
        "path": "/usr/local/jdk-11.0.3",
        "sources" : "/usr/local/jdk-11.0.3/lib/src.zip",
        "javadoc" : "https://docs.oracle.com/en/java/javase/11/docs/api",
        "default":  true
       },
       {
        "name": "JavaSE-12",
        "path": "/usr/local/jdk-12.0.2"
       },
       {
        "name": "JavaSE-13",
        "path": "/usr/local/jdk-13"
       }
    ]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search