Libgdx 无法确定 java 版本 11.0.1

时间:2023-03-02
本文介绍了Libgdx 无法确定 java 版本 11.0.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我尝试了安装所有可能的 Java 文件的所有方法一百万次,我安装了最新的 gradle 版本,但它继续显示此错误.我在 Mac 上.请帮忙谢谢

I tried everything I installed every possible Java file a million times I installed the newest gradle version but it continues to show this error. I'm on Mac. Please help thanks

推荐答案

如果你不想为 Android 开发 Java 11 可以很好地使用 libgdx.

IF you do not want to develop for Android Java 11 works fine libgdx.

您必须在一切构建和运行之前更改一些内容.
这是我为使我的项目正常工作所做的工作.
我的上下文 Mac OSX 10.14 和 openJDK 11.0.2、新项目、桌面启动器和一堆扩展(不重要).

You have to change some things before everything builds and runs.
Here's what I did to get my project working.
My context Mac OSX 10.14 and openJDK 11.0.2, new project, Desktop launcher and a bunch of Extensions (not important).

  1. 你得到的关于找不到 java 11.0.x 的错误来自 gradle.Java 11 仅从 gradle 5 开始支持.为了使用 gradle 5 而不是 4.6 生成的项目配置,请转到 /gradle/wrapper/gradle-wrapper.properties并将 distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip 更改为 distributionUrl=https://services.gradle.org/distributions/gradle-5.0-all.zip.
  1. The error you get about not being able to find java 11.0.x comes from gradle. Java 11 is only supported since gradle 5. In order to use gradle 5 instead of 4.6 the generated project is configured with, go to <project-dir>/gradle/wrapper/gradle-wrapper.properties and change distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip into distributionUrl=https://services.gradle.org/distributions/gradle-5.0-all.zip.

这解决了 java 11 错误,只是为了让您遇到一个新错误Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

That resolves the java 11 error just to confront you with a new error Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

  1. 要摆脱这种情况,请打开 <project-dir>/desktop/build.gradle 并更改第 27 行(您可能会有所不同)
    从文件(sourceSets.main.output.classesDir)
    来自文件(sourceSets.main.output.classesDirs)

  1. To get rid of that, open <project-dir>/desktop/build.gradle and change line 27 (might be different for you)
    from files(sourceSets.main.output.classesDir) into
    from files(sourceSets.main.output.classesDirs)

就是 classesDir 变成 classesDirs

这应该可以解决所有构建错误,您可以开始了.

This should resolve all build errors and you're good to go.

这篇关于Libgdx 无法确定 java 版本 11.0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:Libgdx |场景2d |设置表格的背景颜色? 下一篇:LibGdx 如何重复背景?

相关文章