Android Gradle plugin requires Java 11 to run You are currently using Java 1 8

0 votes

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.

Hope this helps!

Check out java course here to learn more.

Thanks!

Apr 14, 2023 in Flutter by Ashwini
• 5,430 points

edited Jun 22, 2023 by Khan Sarfaraz 7,882 views

1 answer to this question.

0 votes

Based on the error message, the Android Gradle plugin requires Java 11 to run, but you are currently using Java 1.8. You can try one of the following options:

  1. Change the IDE settings You can try changing the settings in your IDE (e.g. Android Studio or VS Code) to use Java 11 instead of Java 1.8.

  2. Change the JAVA_HOME environment variable Set the JAVA_HOME environment variable to point to the Java 11 installation directory. To do this, follow these steps:

  • Determine the path to the Java 11 installation directory.
  • Set the JAVA_HOME environment variable to the path of the Java 11 installation directory.

For example, on Linux, you can set the JAVA_HOME environment variable by running the following command in a terminal:

export JAVA_HOME=/path/to/java-11

On Windows, you can set the JAVA_HOME environment variable by following these steps:

  • Open the Control Panel.
  • Click System and Security.
  • Click System.
  • Click Advanced system settings.
  • Click Environment Variables.
  • Under System Variables, click New.
  • In the Variable Name field, enter JAVA_HOME.
  • In the Variable Value field, enter the path to the Java 11 installation directory.
  1. Change org.gradle.java.home in gradle.properties Set the org.gradle.java.home property in the gradle.properties file to point to the Java 11 installation directory. To do this, follow these steps:
  • Determine the path to the Java 11 installation directory.
  • Open the gradle.properties file in a text editor.
  • Add the following line to the file:
org.gradle.java.home=/path/to/java-11

Replace /path/to/java-11 with the actual path to the Java 11 installation directory.

After making one of these changes, try running the flutter app again and see if the issue is resolved.

answered Apr 14, 2023 by pooja

Related Questions In Flutter

0 votes
1 answer

How to change Android minSdkVersion in Flutter Project?

Yes, you can change the minSdkVersion in ...READ MORE

answered Mar 21, 2023 in Flutter by Tej
7,253 views
0 votes
1 answer

How to save to local storage using Flutter?

Yes, Flutter has a built-in mechanism for ...READ MORE

answered Mar 28, 2023 in Flutter by Tej
1,667 views
0 votes
1 answer

Flutter Outline Shows "Nothing to show" in android studio

There are a few possible solutions for ...READ MORE

answered Mar 30, 2023 in Flutter by vishalini
2,059 views
0 votes
1 answer

Flutter plugin fails to build on iOS

It looks like the error is related ...READ MORE

answered Mar 31, 2023 in Flutter by chandru
1,193 views
0 votes
1 answer

Dart SDK is not configured

The error message "Dart SDK is not ...READ MORE

answered Mar 9, 2023 in Android by pooja
11,345 views
0 votes
1 answer

flutter doctor --android-licenses gives a java error

This error usually occurs because the Java ...READ MORE

answered Mar 24, 2023 in Flutter by venky
3,632 views
0 votes
1 answer

Flutter command not found

This error message usually appears when the ...READ MORE

answered Mar 29, 2023 in Flutter by vishalini
10,134 views
0 votes
1 answer

What is the future of flutter?

Hi@MD, Flutter is a rather new cross-platform framework ...READ MORE

answered Jul 17, 2020 in Others by akhtar
• 38,230 points
903 views
0 votes
1 answer

How to implement in-app update in win32 app using c++

Here is a simplified explanation of the ...READ MORE

answered Apr 11, 2023 in Flutter by seena
313 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP