Wednesday 30 March 2016

java - Unsupported major.minor version 52.0 in my app



I'm trying to compile my Android project and I'm getting this error



[INFO] Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0

[INFO] at java.lang.ClassLoader.defineClass1(Native Method)
[INFO] at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
[INFO] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[INFO] at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
[INFO] at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
[INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
[INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[INFO] at java.security.AccessController.doPrivileged(Native Method)
[INFO] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

[INFO] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
[INFO] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------


I've been reading in other post that try to compile with Java 8 might cause that error but not my case, I have the following Java version:




java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)


OS: Linux Mint
(I'm not have Java 8 installed.)
Build: MAVEN



Can anyone help me with this?



Answer



I face this problem too when making new project from android studio.



I've been able to resolve this by downgrading buildToolsVersion in app gradle setting:
change {module-name}/build.gradle line




buildToolsVersion "24.0.0 rc1"





to




buildToolsVersion "23.0.3"





@Edit:
In Android Studio 2.1 Go to File-> Project Structure->App -> Build Tool Version. Change it to 23.0.3



Do the method above, only when you are using java version 7 and for some reason do not want to upgrade to java 8 yet.




Hope this helps


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...