更新后出现此错误。就像我使用的 android studio 是最新的,java JDK id 17,然后我在 11 中更改它,但仍然无法正确的 Gradle 版本。
请提出像正确的 Gradle 版本这样的想法,我必须在我的项目中使用它。
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'D:\Flutter\suprbFluter\saveCode\fluter\android\settings.gradle' (C:\Users\sonal\.gradle\caches\8.1.1\scripts\ernrjmhpn64ovli3a1sz8s5gv).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 32s
┌─ Flutter Fix ───────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project's Gradle version is incompatible with the Java version that Flutter is using │
│ for Gradle. │
│ │
│ If you recently upgraded Android Studio, consult the migration guide at │
│ https://flutter.dev/to/to/java-gradle-incompatibility. │
│ │
│ Otherwise, to fix this issue, first, check the Java version used by Flutter by running `flutter │
│ doctor --verbose`. │
│ │
│ Then, update the Gradle version specified in │
│ D:\Flutter\suprbFluter\saveCode\fluter\android\gradle\wrapper\gradle-wrapper.properties to be │
│ compatible with that Java version. See the link below for more information on compatible │
│ Java/Gradle versions: │
│ https://docs.gradle.org/current/userguide/compatibility.html#java │
│ │
│ │
└─────────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1
过去两三天我也遇到了这个问题,但我找到了解决方案。问题是您下载的是最新版本的Android Studio,该版本不兼容。您需要下载旧版本的 Android Studio。