简体   繁体   English

语义分析期间的一般错误:不支持 class 文件主要版本 57

[英]General error during semantic analysis: Unsupported class file major version 57

I'm trying to setup libgdx for a desktop game and when I try to generate the project I have this error and the build fails.我正在尝试为桌面游戏设置 libgdx,当我尝试生成项目时出现此错误并且构建失败。 I've the latest versions of Java(13.0.2) and Gradle(6.6), both set as environment variables in the path.我有最新版本的 Java(13.0.2) 和 Gradle(6.6),它们都设置为路径中的环境变量。 Can somebody help me?有人可以帮助我吗?

The error looks like this:错误如下所示:

Could not compile settings file 'C:\Users\noemi\Desktop\Test\settings.gradle'.
> startup failed:
  General error during semantic analysis: Unsupported class file major version 57
  
  java.lang.IllegalArgumentException: Unsupported class file major version 57 

This is not a LibGDX issue.这不是 LibGDX 问题。 Gradle 5 is incompatible with Java 13. You either need to update Gradle (the wrapped version in your project) to Gradle 6 or later, or you need to use a lower version of the JRE. Gradle 5 is incompatible with Java 13. You either need to update Gradle (the wrapped version in your project) to Gradle 6 or later, or you need to use a lower version of the JRE.

To update the wrapped gradle, go to gradle/wrapper/gradle-wrapper-properties in your project and update the version number.将项目中打包的 gradle、go 更新为gradle/wrapper/gradle-wrapper-properties并更新版本号。 I'm using 6.1.1.我正在使用 6.1.1。

distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

If you have an older LibGDX project, you might have to modify the build.gradle file in the android module to be compatible with Gradle 6. You can copy-paste to replace the copyAndroidNatives task with the one here . If you have an older LibGDX project, you might have to modify the build.gradle file in the android module to be compatible with Gradle 6. You can copy-paste to replace the copyAndroidNatives task with the one here .

If you're using eclipse, go to如果您使用 eclipse、go 到

Eclipse > Preferences > Gradle

Update Java home to point to Java home location更新Java home指向 Java home location

This problem occurred when I run my old Flutter project that I coded 2 years ago.当我运行我在 2 年前编写的旧Flutter项目时出现了这个问题。 I think with Android project will also fix in the same way.我认为 Android 项目也将以同样的方式修复。 I'm use MacOS and Android Studio Bumblebee .我正在使用MacOSAndroid Studio Bumblebee

First, need to move to the android folder and check gradle version:首先,需要移动到android文件夹并检查 gradle 版本:

cd android 
./gradlew --version

在此处输入图像描述

It show Gradle version 6.7.1 and you need attention to the JVM line, and my JDK version is 15.0.2.它显示 Gradle 版本6.7.1 ,您需要注意 JVM 行,我的 JDK 版本是 15.0.2。 It is too new for this project.这个项目太新了。 So you must to downgrading from open jdk version to old version or upgrade Gradle version in gradle/wrapper/gradle-wrapper.properties to new version.所以你必须从 open jdk 版本downgrading到旧版本或将gradle/wrapper/gradle-wrapper.properties中的 Gradle 版本upgrade到新版本。

If you downgrade JDK version, you can download from this .如果降级 JDK 版本,可以从这里下载 . In my case, I downgraded from Java SE 15 to Java SE 11.就我而言,我从 Java SE 15 降级为 Java SE 11。

After I open Android of Flutter project在我打开 Flutter 项目的 Android 之后

在此处输入图像描述

Go to Preferences->Build, Execution, Deployment → Build Tools → Gradle → and choose JDK version 11. Go 到Preferences->Build, Execution, Deployment → Build Tools → Gradle →并选择 JDK version 11。 在此处输入图像描述

Go to Build -> Clean Project -> Rebuild Project. Go 构建 -> 清理项目 -> 重建项目。

在此处输入图像描述

Go to Terminal run java --version , if it still show JE version 15 then You must set JAVA_HOME before. Go 到Terminal运行java --version ,如果它仍然显示 JE 版本 15 那么您必须在之前设置 JAVA_HOME。

You only need to add the following to your .bash_profile or .zshrc您只需将以下内容添加到您的.bash_profile.zshrc

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.15.jdk/Contents/Home

Save and go to android folder and run again保存并 go 到android文件夹并再次运行

./gradlew --version

It will show JDK version 11 correct.它将显示正确的 JDK 版本 11。

在此处输入图像描述

Finally, run flutter run .最后,运行flutter run

Check gradle version and bundle version using the following link Link https://developer.android.com/studio/releases/gradle-plugin#updating-gradle使用以下链接检查 gradle 版本和捆绑版本 Link https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

If you want to upgrade android/gradle/build.gradle change dependencies classpath 'com.android.tools.build:gradle: [latest version] '如果要升级 android/gradle/build.gradle 更改依赖项 classpath 'com.android.tools.build:gradle: [latest version] '

startup failed: General error during semantic analysis: Unsupported class file major version 61启动失败:语义分析期间的一般错误:不支持 class 文件主要版本 61

how to fix this react native issues JAVA JDK 17如何解决这个反应原生问题 JAVA JDK 17

Go to the android/ directory of your react-native project Go 到 react-native 项目的 android/ 目录

Create a file called local.properties with this line:使用以下行创建一个名为local.properties的文件:

sdk.dir=C:\Android\sdk sdk.dir=C:\Android\sdk

GOTO android\gradle\wrapper\gradle-wrapper.properties转到android\gradle\wrapper\gradle-wrapper.properties

CHANGE改变

distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip

TO

distributionUrl=https://services.gradle.org/distributions/gradle-7.3-all.zip distributionUrl=https://services.gradle.org/distributions/gradle-7.3-all.zip

GOTO

android\gradle.properties add this line android\gradle.properties 添加这一行

org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

I have downgraded gradle file thats why this error happens so finally I have to change Gradle wrapper file From我已降级 gradle 文件,这就是为什么会发生此错误,所以最后我必须更改 Gradle 包装文件从

distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

to

distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter:无法编译构建文件'build.gradle',语义分析期间的一般错误:不支持的类文件主要版本57 - Flutter: Could not compile build file 'build.gradle', General error during semantic analysis: Unsupported class file major version 57 转换过程中的一般错误:当我构建一个 android 应用程序时,Linux 中不支持的类文件主要版本 61 - General error during conversion: Unsupported class file major version 61 in Linux when I build an android app 安装kafka时如何解决`转换过程中的一般错误:不支持class文件主要版本61` - How to solve `General error during conversion: Unsupported class file major version 61` when install kafka Jenkinsfile 任务失败 [不支持的类文件主要版本 57] - Jenkinsfile task getting faild [Unsupported class file major version 57] 漏洞! 源单元“_BuildScript_”中“语义分析”阶段的异常不受支持 class 文件主要版本 63 - BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63 Cordova - 错误! 源单元“_BuildScript_”中“语义分析”阶段的异常不受支持 class 文件主要版本 63 - Cordova - BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63 无法运行 Gremlin 控制台,因为“线程“主”BUG 中出现异常。“语义分析”阶段出现异常。不支持 class 文件主要版本 62” - Can't Run Gremlin Console due to "Exception in thread "main" BUG! exception in phase 'semantic analysis'... Unsupported class file major version 62" Spark 错误 - 不支持的类文件主要版本 - Spark Error - Unsupported class file major version 构建失败并出现异常。 原因:IllegalArgumentException,消息:不支持 class 文件主要版本 57 - Build failed with an exception. Reason: IllegalArgumentException, message: Unsupported class file major version 57 如何在 Java 13 和 Spring 的 Maven 中修复不受支持的类文件主要版本 57 - How to fix Unsupported class file major version 57 in maven for Java 13 and Spring
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM