I am trying to make a flutter application but I constantly get this error :
* 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`
I followed this question : Android Studio Error "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8"
and this was the output :
------------------------------------------------------------
Gradle 7.4
------------------------------------------------------------
Build time: 2022-02-08 09:58:38 UTC
Revision: f0d9291c04b90b59445041eaa75b2ee744162586
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 13.0.7 (Private Build 13.0.7+5-Ubuntu-0ubuntu120.04)
OS: Linux 5.4.0-125-generic amd64
JVM points to 13.0.7. What can be issue and how can it be resolved? Thankyou
2
Answers
In your Android Studio IDE, go to ~
Preferences → Build, Execution, Deployment → Build Tools → Gradle → *Gradle JDK
and choose the appropriate JDK version and apply. Try to take the embedded JDK as that would be IDE version appropriate. After this sync project and run.
Check your version of Android Studio and update to Dolphin (2021.3.x).
There are plenty of answers to this question out there that simply ask you to point to the right SDK. None of them appreciate that in some 4.x versions of Android Studio, you can be pointing to the right SDK, but Android Studio keeps pointing to the v1.8, even if you have a version >11 installed and selected in:
It’s possible that: C:*java -version –> Results in jre/jvm >11, your ‘flutter doctor -v’ still says: jre/jvm-1.8.
If you don’t see the above screen posted by GeekyChick in settings (i.e., "it’s a location that only opens up a checkbox where its written generate *.iml files"), than you probably have Android Studio v4.x, rather than a 2021.x or greater.
Upgrade your Android Studio to Dolphin, and re-follow the instructions to choose the right SDK in Project Structure (not Settings).