I am trying to code Flutter in Visual Studio, and run the emulator, but every time I do, I get an error. From what I understand, it is asking me to update Java.
I updated Java to version 21, but the issue is still persisting!
How can I fix this?
This message appears
Could not run phased build action using connection to Gradle distribution `'.5-all.zip'`.
`.gradle.api.ProjectConfigurationException`: A problem occurred configuring root project `'android'`.
A problem occurred configuring root project `'android'`.
A problem occurred evaluating root project `'android'`.
A problem occurred configuring project `':app'`.
Build file `'<your_project_path>/android/app/build.gradle' line: 2`
An exception occurred applying plugin request [id: 'com.android.application']
Failed to apply plugin `'com.android.internal.application'`.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Your current JDK is located in `C:\Program Files\Java\jdk1.8.0_161\jre`
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `.gradle.java.home` in `gradle.properties`
I updated Java to version 21. and I expected the error to be resolved and the build to run successfully without issues.
I am trying to code Flutter in Visual Studio, and run the emulator, but every time I do, I get an error. From what I understand, it is asking me to update Java.
I updated Java to version 21, but the issue is still persisting!
How can I fix this?
This message appears
Could not run phased build action using connection to Gradle distribution `'https://services.gradle./distributions/gradle-7.5-all.zip'`.
`.gradle.api.ProjectConfigurationException`: A problem occurred configuring root project `'android'`.
A problem occurred configuring root project `'android'`.
A problem occurred evaluating root project `'android'`.
A problem occurred configuring project `':app'`.
Build file `'<your_project_path>/android/app/build.gradle' line: 2`
An exception occurred applying plugin request [id: 'com.android.application']
Failed to apply plugin `'com.android.internal.application'`.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Your current JDK is located in `C:\Program Files\Java\jdk1.8.0_161\jre`
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `.gradle.java.home` in `gradle.properties`
I updated Java to version 21. and I expected the error to be resolved and the build to run successfully without issues.
Share Improve this question edited Feb 1 at 11:09 Mark Rotteveel 109k229 gold badges156 silver badges220 bronze badges asked Feb 1 at 11:05 Hanady AlzhraniHanady Alzhrani 1 2 |1 Answer
Reset to default -1Try copying your flutter code to a new project check if it runs.
JAVA_HOME
environment variable is set toC:\Program Files\Java\jdk1.8.0_161\jre
, or you don't haveJAVA_HOME
set at all, andC:\Program Files\Java\jdk1.8.0_161\jre
is first on thePATH
. Set theJAVA_HOME
environment variable as the error suggests. – Mark Rotteveel Commented Feb 1 at 11:09