简体   繁体   中英

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

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.

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 .

选择马克

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.

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.

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 ie removed the old version and updated path of JDK. Save.
  2. Sync Project.

Problem solved!

EDIT: Elaborated Project word.

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

I had to update mine to JDK 8.

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 !

Ufff,我改变了我能找到的所有内容到jdk 8并且仍然没有结果但是我在Intellij中找到了Gradle设置(preferences> gradle> GradleJVM)并且它错了,改变了它和woala。


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...

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.

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

It's solved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM