Getting error when trying to run new project in Android Studio 2.2.1

JavaAndroidAndroid Studio

Java Problem Overview


I just updated to Android Studio 2.2.1 for Mac. Then I updated the JDK to version 8. Tried to start a new project and run it. I got the following error:

Error:(1, 1) A problem occurred evaluating project ':app'. > java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

I also tried going back to JDK version 7 as it says on google site that JDK 8 is unstable for Mac. still got the same error.

Java Solutions


Solution 1 - Java

Check your android build tools dependencies. In your build.gradle if its something like:

classpath "com.android.tools.build:gradle:+"

It has likely downloaded the alpha of 2.2 and that can cause the error you are seeing.

Try

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

If you are already using the right build tools version but keep getting this error, maybe one of the third party Android libraries you are using is causing the problem due to the same reason. You can force the dependency version to be used (including transitive) by changing

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

to

classpath('com.android.tools.build:gradle:2.1.0') {
        force = true
    }

Documentation: gist and official gradle docs.

Solution 2 - Java

[![select Mark ][1]][1]

I was also facing same problem. I upgraded Android Studio and as it forced to But we need to configure same in App Settings as well. [1]: http://i.stack.imgur.com/G5D5D.png

Solution 3 - Java

You can try to update JAVA_HOME to point to JDK 8 location.

In my case, I've updated Android studio project's SDK settings, changed java version in my PATH env variable, but still this error occured. Only updating JAVA_HOME helped me.

Solution 4 - Java

I was also facing the same problem. I upgraded Android Studio and as it forced to install JDK 8, downloaded and installed this as well. But we need to configure same in App Settings as well.

  1. Select Project [Right click on the app module] -> Open Module Settings -> Select SDK Location from Left Menu - > Configured correct JDK Version i.e removed the old version and updated path of JDK. Save.
  2. Sync Project.

Problem solved!

EDIT: Elaborated Project word.

Solution 5 - Java

If you are on Jenkins, check Java version in Jenkins->Manage Jenkins->Global Tool Configuration->JDK

I had to update mine to JDK 8.

Solution 6 - Java

I had same error in 2.3 beta 1 ,

Fixed as follow :

Download latest java jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

In Android Studio , go to File > Project Structure > SDK Location > select JDK Location path to point to the new jdk installed (Ex: C:\Program Files\Java\jdk1.8.0_111 )

Done !

Solution 7 - Java

Ufff, I changed like everything I was able to find to jdk 8 and still no result but then I found Gradle settings in Intellij (preferences > gradle > GradleJVM) and it was ofc wrong, changed that and woala.

Solution 8 - Java


I meet the problem too, but I have changed nothing before it's happening. I think google is purposely. Google is trying to use openJDK instead of JDK because of the lawsuit between google and oracle. So, in the new version 2.2.0 of android, we found that there are some new files in the installed folder:

android studio 2.1 files

android studio 2.2 files

Then, I think we have two method to fix it:

  1. Change the JDK environment variable of your OS.

  2. Just click menu File --> Project Structure, choose Use embedded JDK (recommended). I chose this way and it work.

Good luck...

Solution 9 - Java

I had a same problem what is work for me is that .

Go *File>Settings>(on the panel left)Build,Execution,Deployment . then click on Gradle

There is option to Update Gradle. Click on that it will time 3 to 4min and after that error gone.

Solution 10 - Java

The simplest way is to update Android Studio to v2.2.3, it includes a fix of JDK8:

It's solved my problem.

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
QuestionIntangibleTechView Question on Stackoverflow
Solution 1 - JavaEricMorentinView Answer on Stackoverflow
Solution 2 - JavaAshish ChauguleView Answer on Stackoverflow
Solution 3 - JavaVadim KotovView Answer on Stackoverflow
Solution 4 - JavaKanak SonyView Answer on Stackoverflow
Solution 5 - JavaViliusKView Answer on Stackoverflow
Solution 6 - JavaAlin RazvanView Answer on Stackoverflow
Solution 7 - JavaSrneczekView Answer on Stackoverflow
Solution 8 - JavaSmith JohnView Answer on Stackoverflow
Solution 9 - JavaUsman lqbalView Answer on Stackoverflow
Solution 10 - JavasuperuserView Answer on Stackoverflow