2

This is probably a cliché question that was repeated a trillion times. But I'm asking here because I became fully and totally desperate and I need some pointers to continue.

I'm learning how to program games using LibGDX. I'm using this tutorial. The problem is the classic error:

Errors occurred during the build. Errors running builder 'Android Package Builder' on project 'HelloWorld-android'. com/android/dx/command/dexer/Main : Unsupported major.minor version 52.0

I understand that this error means that some how, Eclipse is using Java 8 to compile, and an earlier version of Java to run, which is creating this incompatibility. But guess what? I don't even have Java 8 on my computer! I have:

  1. Android SDK
  2. Java 7u79
  3. Eclipse Luna
  4. LibGDX, that generates the project for me.

I don't understand why this is happening, so please assist and tell me why this would happen. Following are screenshots of Eclipse showing that everything is 1.7.

enter image description here

enter image description here

enter image description here

And yet I keep getting this error on right click -> Debug As -> Android Application:

enter image description here

What did I miss? Where is Java 52 coming from?

I would like to point out that the Desktop version of the game runs with not a single problem.

Thank you for any efforts. Please don't hesitate in asking for more information.

The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
  • Did you try a clean/rebuild yet? – Compass Jun 22 '16 at 19:36
  • something you have was compiled for java 8 (http://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi) you can't use that though – zapl Jun 22 '16 at 19:37
  • @Compass absolutely! Many times. – The Quantum Physicist Jun 22 '16 at 20:03
  • @zapl Thanks a lot for the link. I'll look into that link when I reach home. But I'd like to point out that I recreated the project a dozen of times. – The Quantum Physicist Jun 22 '16 at 20:06
  • You are correct about wrong version of compiler for the project. I would suggest checking the project facet if it's not set to Java8. If you are using Maven, you might want to check the `pom.xml` to confirm the `java.compiler` is set to correct version. –  Jun 22 '16 at 20:10
  • @zapl I spend another hour digging with this link and its possible solutions... nothing worked! I even added the parameter to the compilter `-target 1.7`, and that didn't help either. There's a Java 8 hiding somewhere. How can I find it? That's my main question! – The Quantum Physicist Jun 22 '16 at 21:23
  • @jmsweb I use Gradle actually (well, not me, libgdx creates a gradle project). – The Quantum Physicist Jun 22 '16 at 22:21
  • Android SDK 24.1.1 supports Java8. What's your Android SDK version? –  Jun 22 '16 at 23:07
  • @jmsweb It's 24.4.1... Do you think I should move to JDK 8? I just didn't do it because I heard many people saying it's not a good idea and has compatibility issues. – The Quantum Physicist Jun 22 '16 at 23:09
  • I haven't tried Android development but their requirement seem to specify Java8 for a reason. Maybe newer Android SDK included Lambda functions. –  Jun 22 '16 at 23:14
  • I think you have couple of options. You could download older Android SDK with support for Java7, or give in and install Java8. Please update us with your result. –  Jun 23 '16 at 00:51
  • @jmsweb Well I have to say that it had worked for one day... But then I did many different things and don't know what made it not work anymore. So I wouldn't be too sure that Android SDK is not compatible with Java 7. I'm planning to move to Java 8 today... I really gave up. I'll let you know how it goes. Thanks for trying to help. – The Quantum Physicist Jun 23 '16 at 06:40

1 Answers1

1

It's not your code that requires Java 8.

"Error running builder 'Android Package Builder'

means something in the android build tools, some of which are also written in Java, require Java 8 to run.

You'll have to install Java 8 so that it runs Eclipse & gradle. Java 8 can compile for Java 7, so you don't have to change the project to Java 8 (which would also mean the app would only work with Android N and above).

The safest bet is to remove all Java < 8 versions from your computer, that way you can't accidentally run with an older version. You'll have to update the "installed JREs", set the default (& especially the one in the gradle screen) to your Java 8 install, but keep the project's "Compiler compliance level" at 1.7.

zapl
  • 63,179
  • 10
  • 123
  • 154
  • Actually this gives me an idea... I will use the JDK 7 compiler, but I'll install the Java 8 runtime. If that doesn't work, I'm moving to Java 8 fully. – The Quantum Physicist Jun 23 '16 at 08:11
  • I gave up... I moved to Java 8 and it works now... I just hope I'll not have any back-compatibility issues when I set compliance level to an earlier version. – The Quantum Physicist Jun 23 '16 at 08:53