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:
-
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.
-
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.
- 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.