Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio continues to get a Unsupported major.minor version 52.0

After merging my project with some changes from other developers I continue to get the following:

Error:Cause: com/android/build/gradle/internal/model/DefaultAndroidProject : Unsupported major.minor version 52.0

I've tried installing Java 8, and setting my project to use Java 8. If I change my JAVA_HOME to 1.8 on the command line and compile with gradle it works. If I try to use JAVA_HOME set to 1.7 and gradle it fails with the same error.

However, in Android Studio, no matter the JDK version, it continues to print that error.

Other developers are saying they are using Java 7 without issue. Other things I've tried:

gradle clean build
gradlew clean build
Reinstalling Android Studio

Another interesting symptom is that other projects in Android Studio are perfectly happy. It's just this project that has this problem.

Here are my environment settings:

OS: Mac OS X 10.9.5
Android Studio: 2.1.1
Android Studio JVM: 1.6
Project JVM: 1.7.0_75
Android SDK (Build Tools): 23.0.2
Gradle: 2.13
JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
ANDROID_HOME: /Users/me/Library/Android/sdk

I suspect it has something to do with the gradle wrapper, but I can't figure out how to get graddle wrapper to reinitialize itself using 1.7.

like image 986
chubbsondubs Avatar asked May 26 '16 16:05

chubbsondubs


People also ask

How to fix Unsupported major minor version 52. 0?

The exact cause is printed on the version e.g. in the case of major. minor version 52.0, the class is compiled using JDK 8 since major version 52 corresponds to Java SE 8. This error can usually be fixed by running the application on the same (or higher) JRE version as the JDK.

What is Java version 52. 0?

minor version 52.0 comes when you are trying to run a class compiled using Java 1.8 compiler into a lower JRE version e.g. JRE 1.7 or JRE 1.6. Simplest way to fix this error is install the latest Java release i.e. Java 8 and run your program.


3 Answers

Try menu File - > Invalidate caches and restart. Also make sure gradle plugins are latest:

classpath 'com.android.tools.build:gradle:2.1.0'
like image 84
Stepan Maksymov Avatar answered Nov 10 '22 04:11

Stepan Maksymov


Set your JAVA_HOME to use jdk 1.8.

Also check your SDK location in Android Studio:

File->Other Settings->Default Project Structure->SDKs

enter image description here

like image 22
Entreco Avatar answered Nov 10 '22 04:11

Entreco


This got me working on my MAC:

Goto>> File > Project Structure... > SDK Location (in left column) > JDK location section: Check Use embedded JDK (recommended)

enter image description here

like image 30
thatzprem Avatar answered Nov 10 '22 03:11

thatzprem