Search code examples
androidfluttergradle

How to resolve "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8", when I am using Java 11


I imported a Flutter project into Visual Studio Code, and when I tried to run it, I got this error message:

FAILURE: Build failed with an exception.

  • Where: Build file '/home/omer358/FlutterProjects/MyProjects/ConverterNOW/android/app/build.gradle' line: 24

  • What went wrong: A problem occurred evaluating project ':app'.

Failed to apply plugin 'com.android.internal.application'. Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. You can try some of the following options: - changing the IDE settings. - changing the JAVA_HOME environment variable. - changing org.gradle.java.home in gradle.properties.

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

I searched for some solutions, one of them suggested that I'm using java1.8 but that was not the case; omer358@OMO:~/FlutterProjects/MyProjects/ConverterNOW/android$ ./gradlew --version returns:

------------------------------------------------------------
Gradle 7.0.2
------------------------------------------------------------

Build time: 2021-05-14 12:02:31 UTC
Revision: 1ef1b260d39daacbf9357f9d8594a8a743e2152e

Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.14 (Ubuntu 11.0.14+9-Ubuntu-0ubuntu2.22.10)
OS: Linux 5.13.0-35-generic amd64

Can you help me make go away?


Solution

  • Is your place set up?

    Is the gradle java version too low

       JAVA_HOME D:\Android\Android Studio\jre
       %JAVA_HOME%\bin
    

    enter image description here