[英]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
.我正在使用
MacOS
和Android 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.