简体   繁体   中英

Why I have an error in the android folder about Java in Flutter?

Every time I make a Flutter project this error. He appears to me and I don't know why.

[{
    "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
}]

错误

I searched in VS Code but couldn't find a solution.

I see that the fix for the problem is mentionned, you have an old version of java and you need to update it so it will be compatibe sith the verion of gradle you're using, you can download last version of java from here:

https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html

after it's installed, try again with same operation ans it should work!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM