admin管理员组

文章数量:1312692

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
  • 3 It sounds like your JAVA_HOME environment variable is set to C:\Program Files\Java\jdk1.8.0_161\jre, or you don't have JAVA_HOME set at all, and C:\Program Files\Java\jdk1.8.0_161\jre is first on the PATH. Set the JAVA_HOME environment variable as the error suggests. – Mark Rotteveel Commented Feb 1 at 11:09
  • 3 Yea ... when an error message suggests some things that you can try to fix a problem. it is a good idea to try them. – Stephen C Commented Feb 1 at 12:05
Add a comment  | 

1 Answer 1

Reset to default -1

Try copying your flutter code to a new project check if it runs.

本文标签: flutterGradle not detecting Java 21 after update – how to fixStack Overflow