为什么我在Android文件夹中有一个关于Flutter中Java的错误?

sqxo8psd  于 2022-01-24  发布在  Flutter
关注(0)|答案(1)|浏览(245)

每次我做一个Flutter项目这个错误。他出现在我面前,我不知道为什么。

[{
    "resource": "/E:/code/flutterProjeket/nootafterget/android/",
    "owner": "_generated_diagnostic_collection_name_#5",
    "code": "0",
    "severity": 8,
    "message": "Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.4-all.zip'.\r\norg.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'android'.\r\nA problem occurred configuring root project 'android'.\r\nA problem occurred evaluating root project 'android'.\r\nA problem occurred configuring project ':app'.\r\nA problem occurred evaluating project ':app'.\r\nFailed to apply plugin 'com.android.internal.application'.\r\nAndroid Gradle plugin requires Java 11 to run. You are currently using Java 1.8.\nYou can try some of the following options:\n  - changing the IDE settings.\n  - changing the JAVA_HOME environment variable.\n  - changing `org.gradle.java.home` in `gradle.properties`.",
    "source": "Java",
    "startLineNumber": 1,
    "startColumn": 1,
    "endLineNumber": 1,
    "endColumn": 1
}]

我在VS Code中搜索,但找不到解决方案。

h79rfbju

h79rfbju1#

我看到问题的修复被提及,你有一个旧版本的java,你需要更新它,这样它将与你正在使用的gradle版本兼容,你可以从这里下载最新版本的java:
https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html
安装后,请使用相同的操作重试,它应该可以正常工作!

相关问题