7

I just tried to update Android studio from 1.4 to 2.2 preview 2. After updating Android Studio, when I tried to open it, it showed me this error:

Error:(1, 1) A problem occurred evaluating project ':app'.

java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

enter image description here

Can any one help me to resolve this?

Community
  • 1
  • 1
fazil
  • 1,155
  • 11
  • 24

2 Answers2

11

I spent quite a lot of time with this one in Android Studio too.

It seems this problem is caused by the difference in java version used for compiling the project.

Finally, inside the "Project Structure" settings window, I enabled the "Use embedded JDK (recommended)" in the SDK location tab.

And happy compiling :)

Graph
  • 592
  • 7
  • 13
  • 1
    Windows java auto updater just create new directories for new releases of JDK but Android Studio keeps pointing to an old JDK directory... so do as Graph said or just point to a newer JDK path. – Mar Bar Jun 24 '17 at 12:07
2

Your runtime environment is running a different version of Java than your compiler - 52.0 represents Java SE 8

On Linux, type:

sudo update-alternatives --config java

Output will be like:

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                     Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-oracle/jre/bin/java   2         auto mode
  1            /usr/lib/jvm/java-7-oracle/jre/bin/java   2         manual mode
* 2            /usr/lib/jvm/java-8-oracle/jre/bin/java   1         manual mode

Press <enter> to keep the current choice[*], or type selection number: 

Select 2

Then compile your project:

./gradlew assembleDebug

This fixed it for me:)

On Windows, you can do it via the Java Control Panel very easily - read more about it here!

Wills
  • 61
  • 4