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

 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

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!

[email protected]:~/FlutterProjects/MyProjects/ConverterNOW/android$ ./gradlew --version

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 1: LiangKe

Is your place set up?

Is the gradle java version too low

   JAVA_HOME D:\Android\Android Studio\jre

enter image description here

Solution 2: Chinecherem Tina

I got the same problem but what I did is that I deleted the android folder and run it again. If your are using android studio, in your terminal past this Flutter create . and it will build the android project using your specified SDK instead

Solution 3: Matthew Trent

The headache-less solution:

Just uninstall your (older) version of android studio, go to their website, and install the latest version. This should automatically update your java version to whatever your Flutter project requires.

Worked for me after trying lots of other methods.

Solution 4: Matthew Ma

For anyone who tried java -version and still failed even though you have the correct version or higher, go to folder android > gradle.properties and add this: org.gradle.java.home={your jdk directory}, I attached mine as example


Solution 5: Luis Lobo

I had that problem and I had solved it doing this:

Add the command below in gradle.properties file:

org.gradle.java.home=C:\Program Files\\Java\\jdk-

In my case:

org.gradle.java.home=C:\Program Files\\Java\\jdk-

Then, in terminal, change the directory to android. (I use windows)

cd android

Finally, i wrote ./gradlew signingreport in terminal and i got SHA1 and SHA-256.

Solution 6: ishak

in my mac, there is no gradle projects settings, so this is what i solved my problem:

1. Open project structure in android studio

2. Follow platform settings > android studio default JDK

3. Then download JDK with this settings

Solution 7: Ahmed Soliman

in vs code in ur explorer open android>app>gradle.properties and then add this code

org.gradle.java.home=C:\\Program Files\\Java\\jdk-18.0.2

if u use another version of jdk then replace jdk-18.0.2 to jdk-ur version the all code in gradle.properties should be like this

org.gradle.java.home=C:\\Program Files\\Java\\jdk-18.0.2

Solution 8: Raghu Vallikkat

In my case , running flutter app with VS code in mac M1, had similiar issue

I have added the below line in gradle.properties


Note: Initially I added the value in ''. ie org.gradle.java.home='/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home'

then it gave error. later I removed ''

Solution 9: ArmandoHackCode

I found myself with the exact same problem, I searched a lot how to make the sdk changes, tried many of the solutions that are mentioned in several POSTs and nothing seemed to work or solve the problem, however the one that did work provisionally was to overwrite the version from gradle.properties with


But it turns out that the problem was with Android Studio, previous versions by default handle JRE 1.8 and to have it functional with v11, you just have to update android studio to its most recent version, I installed Android Studio Dolphin | 2021.3.1

Here I leave the screenshots to identify the case.

Console problem running a Flutter project

enter image description here enter image description here

Result of the flutter doctor before

enter image description here

Result of flutter doctor after updating android studio to its latest version

enter image description here

Solution 10: Akashgreninja

None of the above solutions worked for me I use Vs Code btw so the thing I did was first go to android->build gradle and look for this line of code

dependencies {
    classpath 'com.android.tools.build:gradle:7.1.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"


dependencies {
    classpath 'com.android.tools.build:gradle:4.1.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

changed the version.This will work for sure if the above methods didnt