【Flutter】exception in phase ‘semantic analysis‘ in source unit ‘_BuildScript_‘ Unsupported class

Gradle版本与Java(JDK)版本不兼容问题系列一

问题描述

Could not open settings generic class cache for settings file .BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class    file major version 61

在这里插入图片描述


原因分析:

Gradle版本与Java版本不兼容问题,.gradle\cache\6.5说明当前项目的Gradle 版本是6.5,Gradle 6.5对应版本Java8(即常说的JDK1.8)~Java14。
Gradle官方的兼容性文档


解决方案:

在android项目里修改Gardle版本即可,操作如下:

File>open>当前项目下的android项目>Project Structure>SDK Location>Gradle
Settings>Gradle JDK 修改成需要的Java(即JDK)版本。

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
下一篇 Gradle版本与Java(JDK)版本不兼容问题系列二

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! Launching lib\main.dart on AOSP on IA Emulator in debug mode... Support for Android x86 targets will be removed in the next stable release after 3.27. See https://github.com/flutter/flutter/issues/157543 for details. Running Gradle task 'assembleDebug'... FAILURE: Build failed with an exception. * What went wrong: Could not open cp_settings generic class cache for settings file 'D:\and sroid\Android\work\untitled5\android\settings.gradle' (C:\Users\����һ����\.gradle\caches\7.5\scripts\cgwnh8p454v85dv1xmzoedwjx). > 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 1s ┌─ 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/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 versio
03-18
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值