Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
126 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...