问题
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
回答1:
IF you do not want to develop for Android Java 11 works fine libgdx.
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).
- 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 changedistributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
intodistributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
.
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.
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)
intofrom files(sourceSets.main.output.classesDirs)
thats
classesDir
intoclassesDirs
This should resolve all build errors and you're good to go.
回答2:
I am strongly recommend to use Java version not greater than 8. It is many incompatibility issues I faced just on 9 version of JDK in Android Dev environment.
Uninstall all java you have, use this article, because it is not as such easy without knowledge: https://www.java.com/en/download/help/mac_uninstall_java.xml
After download the 8th version from here: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
I did same some time ago and all problems left
来源:https://stackoverflow.com/questions/53600893/libgdx-could-not-determine-java-version-11-0-1