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?


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


Gradle Scripts >> build.gradle (Module app)

Change buildToolsVersion "24.0.0" to buildToolsVersion "23.0.3"

source : experience


Initially I had downgraded buildToolsVersion from 24.0.0 rc3 to 23.0.3, as specified in Rudy Kurniawan's answer. Then I have noticed that I have jdk 7 specified in my project settings. I have changed it to jdk 8 and now build tools 24.0.0 rc3 work.

enter image description here

It's also important to have compile options set to java7:

android {
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

I installed Android Studio alongside to Xamarin Visual Studio (was already installed). After the installation (excluded SDK, because they were already installed) I started Android Studio and it downloaded, installed and added missing SDKs (after giving the path to the SDK location). As a result I got the error message on build

java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0

As a solution I installed jdk-8u101-windows-i586.exe without JRE (because it was already installed). Before I tried the x64 version, but it disappeared ... Then you have to change the Java Development Kit location.

Change JDK location

This is done in Visual Studio by clicking Tools > Options > Xamarin > Android Settings. Here you can navigate to the correct location. In my case it was C:\Program Files (x86)\Java\jdk1.8.0_101.

Finally, clean your project and make a new build :-)


The problem specified:

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

is caused when is declared inside the build.gradle, buildToolsVersion 24 and we don´t have Java 8 installed that is required for this version. To solve this problem we have to change from buildToolsVersion from 24 to maximum 23:

enter image description here

Java 8 must be required in the future for Android Studio, so we have to start using Java 8.