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

AndroidAndroid StudioGradle

Android Problem Overview


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.

Android Solutions


Solution 1 - Android

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

classpath 'com.android.tools.build:gradle:2.1.0'

Solution 2 - Android

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

Solution 3 - Android

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

Solution 4 - Android

Fix for me was

  1. Update android studio to latest (2.2 as of now)

  2. Install SDK 24

Solution 5 - Android

Try setting the STUDIO_JDK environment variable. What has worked for me is:

launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_76.jdk

Obviously, replace 1.8.0_76 with whatever version of JDK 8 you have installed. I've been lazy and haven't taken the time to figure out the right way to make this work across reboots (I usually just have to run that every time I reboot) but that should do the trick for you.

Solution 6 - Android

If you're seeing this error you need to update your JDK in "Project Structure" options.

This is found under File > Project Structure > SDK. Or from the welcome screen in Configure > Project Defaults > Project Structure.

Select the Use the embedded JDK (recommended) option instead of using your own JDK.

Solution 7 - Android

open file "/Application/Android Studio/Contents/info.plist", find key "JVMVersion" replace it to 1.8.x (this is your Java version, before doing it, you should install JDK 1.8.x or above)

Solution 8 - Android

What eventually worked for me was to set the gradle JVM setting.

On mac, Go to

Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle

Set the Gradle JVM dropdown to use Java 1.8. Mine was set to 1.7.

Note: I also made the SDK location change that Entreco posted, but do NOT have the JAVA_HOME environmental variable set.

Solution 9 - Android

Try File -> Project Structure -> SDK Location

I had the same problem because gradle was using my old JDK.

Solution 10 - Android

Check your SDK location in Android Studio:

File->Project Structure->SDK Location

> Set JDK location: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

enter image description here

Solution 11 - Android

Check your Project SDK Location if it is JAVA 1.8

than maybe you should check your Project gradle JVM setting too

Solution 12 - Android

I also had this problem, It's resolved when I update my JDK and change the location of JDK in android to the latest version.

File->Other Settings->Default Project Structure->JDK Location (Change to the latest version, mine is resolved after changing to jdk1.8.0_92)

Solution 13 - Android

Are you targeting N? That will require you to use java 8.

Solution 14 - Android

don't use gradle with alpha version

Solution 15 - Android

There can be two main reasons to occur this problem.

  1. Java Version Problem

Check the compatible java version and update your development environments JDK to same version.

  1. Gradle Version Problem

This basically the problem in gradle version. Please check project gradle version is equal to gradle version that you are using in your development environment

Solution 16 - Android

this problem will accure when you transfer your project to another computer and the installed google.play.service not same the figured out workaround is remove the check of the google play services from the SDK tools window, update and reset your android studio then download and reinstall them from the SDK manager tool

Solution 17 - Android

I had the same problem a while ago. It was actually caused by wrong path in the settings! Since after update, AndroidStudio 2.3 installed itself to C:\Program Files\Android\Android Studio1 and the path was set to C:\Program Files\Android\Android Studio\gradle\gradle-2.10 instead of C:\Program Files\Android\Android Studio1\gradle\gradle-2.10

Really a stupid problem, but fortunately with a simple solution .)

Solution 18 - Android

Android Studio behaves weird in the case. Even though you set the JDK version in File -> Project Structure -> SDK Location, Android Studio only uses this for compiling the files. When it runs these files it, for some reason, uses the version of java installed system wide, i.e. in usr/local/bin.

So you have to set your path variable to point to the same version of java that have set in your Android studio project settings.

>export PATH="/Applications/studio.app/Contents/jre/jdk/Contents/Home/bin:$PATH"

In my case my project was configured to use java 1.8, but my system wide installation of java was java 1.7. This was causing the issue.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionchubbsondubsView Question on Stackoverflow
Solution 1 - AndroidStepan MaksymovView Answer on Stackoverflow
Solution 2 - AndroidEntrecoView Answer on Stackoverflow
Solution 3 - AndroidthatzpremView Answer on Stackoverflow
Solution 4 - AndroidSourabh SaldiView Answer on Stackoverflow
Solution 5 - AndroidKevin CoppockView Answer on Stackoverflow
Solution 6 - AndroidFawadView Answer on Stackoverflow
Solution 7 - AndroidgaillysuView Answer on Stackoverflow
Solution 8 - AndroidSanjView Answer on Stackoverflow
Solution 9 - AndroidAdil AliyevView Answer on Stackoverflow
Solution 10 - AndroidZhou KalicyView Answer on Stackoverflow
Solution 11 - AndroidIronView Answer on Stackoverflow
Solution 12 - AndroidMufasil FaizalView Answer on Stackoverflow
Solution 13 - AndroidTyler PfaffView Answer on Stackoverflow
Solution 14 - AndroidMaoView Answer on Stackoverflow
Solution 15 - AndroidChinthaka DinadasaView Answer on Stackoverflow
Solution 16 - AndroidHamid JolanyView Answer on Stackoverflow
Solution 17 - AndroidLukáš ZelenkaView Answer on Stackoverflow
Solution 18 - Androiduser3282666View Answer on Stackoverflow