Android Studio 继续获得不受支持的 Major. small 版本52.0

在将我的项目与其他开发人员的一些更改合并之后,我继续得到以下内容:

Error:Cause: com/android/build/gradle/internal/model/DefaultAndroidProject : Unsupported major.minor version 52.0

我尝试安装 Java8,并将我的项目设置为使用 Java8。如果我在命令行上将 JAVA _ HOME 更改为1.8,并使用 gradle 进行编译,那么它就可以工作了。如果我尝试使用 JAVA _ HOME 设置为1.7并进行分级,它也会出现同样的错误。

但是,在 Android Studio 中,无论 JDK 版本如何,它都会继续打印该错误。

其他开发人员说他们使用 Java7没有问题,我试过的其他方法:

gradle clean build
gradlew clean build
Reinstalling Android Studio

另一个有趣的症状是 Android Studio 中的其他项目都非常满意。只是这个项目有个问题。

以下是我的环境设置:

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

我怀疑它与 graddle 包装器有关,但我不知道如何使用1.7使 graddle 包装器重新初始化它自己。

100311 次浏览

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

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

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

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.

don't use gradle with alpha version

Try File -> Project Structure -> SDK Location

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

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

Check your Project SDK Location if it is JAVA 1.8

than maybe you should check your Project gradle JVM setting too

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)

Fix for me was

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

2) Install SDK 24

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)

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

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

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.

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

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.

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

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

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.