0
votes

All of the sudden my app stopped building in Android Studio. The message:

UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472) at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406) at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388) at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251) at com.android.dx.command.dexer.Main.processClass(Main.java:704) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at com.android.dx.command.dexer.Main.access$300(Main.java:83) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main.processOne(Main.java:632) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106) ...while parsing pl/qus/xenoamp/helper/XenoScala$.class 1 error; aborting

I didn't change JDK version or AS version...

But then I've checked default Java environment and it was set to 1.8. Changing it to 1.7 gave different error:

Error:Cause: scala/util/Properties$ : Unsupported major.minor version 52.0

More info: although my Scala library is compiled for 60.0 (Java 6), during build gradle caches a version that is built indeed for 52.0 in:

~.gradle\caches\modules-2\files-2.1\org.scala-lang\scala-library\2.12.0-M2\8453b80505a57d429f321b94e1fb4ca09b037fc0

What's wrong? What can I do?!

3

3 Answers

0
votes

According to this answer, it appears that the cause of the ParseException is the use of Java 1.8.

It appears that the "Unsupported major.minor version 52.0" error is due to the runtime being incompatible with the compile time code. I believe that major.minor 52.0 corresponds with Java 1.8, whereas 51.0 with Java 1.7. Likely by completely rebuilding your project with Java 1.7 will make the problem go away.

0
votes

Switch to 1.7 and make sure any libraries you depend on (in particular, the scala standard library) are built for 1.7 - from that error it seems the scala.util.Properties on your classpath (i.e. the scala standard library) was built for 1.8.

0
votes

OK, again for future reference. This was caused by a small change in build.gradle. From

compile 'org.scala-lang:scala-library:2.11.+'

to

compile 'org.scala-lang:scala-library:2.+'

Scala 2.11 is compiled to Java 6, Scala 2.12 - to Java 8