0

When I try to run flutter app on vs code. I get this error:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/aman/Desktop/arjun_malhotra/flutter_Projects/isolates_demonstration/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 3s
Running Gradle task 'assembleDebug'...                              4.5s

┌─ Flutter Fix ───────────────────────────────────────────────────────────────────────────────────────────────────┐
│ [!] You need Java 11 or higher to build your app with this version of Gradle.                                   │
│                                                                                                                 │
│ To get Java 11, update to the latest version of Android Studio on https://developer.android.com/studio/install. │
│                                                                                                                 │
│ To check the Java version used by Flutter, run `flutter doctor -v`.                                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1

I tried the solution mentioned in this answer


------------------------------------------------------------
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-146-generic amd64

But I dont see my JVM pointing to 1.8 version. How do I resolve this? enter image description here Also I dont see any gradle option from where I can change version.

Arjun Malhotra
  • 351
  • 2
  • 11

1 Answers1

0

Download and install JDK11 or newer, configure it properly, and point your project to it.

That's all there is to it really. Of course you may need to make changes to your project to compensate for changes in the language and standard libraries, but that's a different concern.

jwenting
  • 5,505
  • 2
  • 25
  • 30