我正在创建 flutter 项目,我在 android studio 中发现了这个错误,即 Gradel Issu 错误显示了这个
Launching lib\main.dart on RMX2151 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not open cp_settings generic class cache for settings file 'C:\Users\HP\AndroidStudioProjects\untitled\android\settings.gradle' (C:\Users\HP\.gradle\caches\7.6\scripts\1xnftno0sh94ll65ky75jq782).
> 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 856ms
┌─ 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 │
│ docs.flutter.dev/go/android-java-gradle-error. │
│ │
│ 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 │
│ C:\Users\HP\AndroidStudioProjects\untitled\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 │
│ │
│ │
└─────────────────────────────────────────────────────────────────────────────────────────────────┘
我尝试按照 chatgtp 告诉我的那样进行更改,即使我更改了 Gradel Wrapeer prperti 中的网址,但这个错误在我的项目中仍然存在,但我仍然看到了这个错误
我使用java 17和fpr Gradel url distributionUrl=https://services.gradle.org/distributions/gradle-7.6-all.zip
有人可以解释一下解决这个错误吗
此问题主要是由于 Android Studio LadyBug 的新更新导致其与 java-21 运行不兼容。要解决此问题,请参阅以下问题 - stackoverflow-issue-with-java-21