Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported major.minor version 52.0 2.5.0 #74

Closed
avestnik opened this issue Dec 15, 2014 · 36 comments
Closed

Unsupported major.minor version 52.0 2.5.0 #74

avestnik opened this issue Dec 15, 2014 · 36 comments

Comments

@avestnik
Copy link

keep getting error in Android Studio 1.0.1

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'me.tatarka:gradle-retrolambda:2.5.0'
    }
}

repositories {
    mavenCentral()
}

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'

retrolambda {
    jdk System.getenv("JAVA8_HOME")
    oldJdk System.getenv("JAVA7_HOME")
    javaVersion JavaVersion.VERSION_1_7
    jvmArgs '-arg1', '-arg2'
}

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.aaa.bbb.android"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

JAVA7_HOME=C:\Program Files\Java\jdk1.7.0_65
JAVA8_HOME=C:\Program Files\Java\jdk1.8.0_25
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_25

@aleks-tpom6oh
Copy link

I am getting exactly the same error with same setup

@tomrozb
Copy link

tomrozb commented Dec 23, 2014

Same here.

Caused by: java.lang.UnsupportedClassVersionError: me/tatarka/RetrolambdaPlugin : Unsupported major.minor version 52.0
  at org.gradle.api.internal.plugins.DefaultPluginRegistry.getTypeForId(DefaultPluginRegistry.java:104)
  at org.gradle.api.internal.plugins.DefaultPluginContainer.getTypeForId(DefaultPluginContainer.java:183)
  at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:103)
  at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:115)
  at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
  at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
  at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:131)
  at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:37)
  at org.gradle.api.Project$apply$0.call(Unknown Source)
  at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
  at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
  at build_aaf1sc683lzoi46tbsb8qzj2v.run(/home/tomrozb/workspace/bb/app/build.gradle:2)
  at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
  ... 42 more

@evant
Copy link
Owner

evant commented Dec 23, 2014

What version of java are you running gradle with?

@avestnik
Copy link
Author

I tried both 1.7.0.65 and 1.8.0.25. Both Java and windows 8.1 are 64 bits

@dlew
Copy link

dlew commented Dec 24, 2014

I ran into this as well.

The interesting tidbit I have to contribute is that NOT having a JAVA_HOME defined makes the build work. In other words: if I define just JAVA8_HOME it works, but if I have both JAVA_HOME and JAVA8_HOME I get this error.

@fada21
Copy link

fada21 commented Dec 27, 2014

I had the same problem. I tried changing JAVA_HOME in several variations but it didn't help.

My solution was changing JDK location in module settings in Android Studio.
androidstudioretrolambdasolution
Before this change it was set to java7 which was not working for me.

My build.gradle relevant parts look like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.fada21.android.x"
        minSdkVersion 10
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

apply plugin: 'me.tatarka.retrolambda'
retrolambda {
    jvmArgs '-noverify'
    jdk System.getenv("JAVA8_HOME")
    oldJdk System.getenv("JAVA7_HOME")
    javaVersion JavaVersion.VERSION_1_7
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:21.0.3"

    retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:1.+'
}

@tomrozb
Copy link

tomrozb commented Dec 29, 2014

@fada21 solution doesn't work for me because I've already set it to the same path.

@tomkoptel
Copy link

Any progress on this issue?

I`m experiencing same problem on my Ubuntu machine:

Environment

export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
export JAVA6_HOME="/usr/lib/jvm/java-6-oracle"
export JAVA7_HOME="/usr/lib/jvm/java-7-oracle"
export JAVA8_HOME="/usr/lib/jvm/java-8-oracle"

Gradle script

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
        classpath 'me.tatarka:gradle-retrolambda:2.5.0'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

retrolambda {
    jdk System.getenv("JAVA8_HOME")
    oldJdk System.getenv("JAVA6_HOME")
    javaVersion JavaVersion.VERSION_1_6
}

dependencies {
    compile project(":rest")
    compile 'com.jakewharton.timber:timber:2.5.0'
    compile 'io.reactivex:rxandroid:0.23.0'
    compile 'com.squareup.retrofit:retrofit:1.8.0'
}

Any explanation what does this message really mean?

@bennythomps
Copy link

Just a heads up, it was as simple as changing the SDK path in project settings to point to my JDK 8 home directory. I had started my project before including this plugin and was at that pointed to 7, but during setup for this library installed 8, but didn't update my project settings. Updating the path fixed the issue for me. HTH

@fada21
Copy link

fada21 commented Jan 21, 2015

@tomkoptel Have you changed SDK path in project settings as @bennythomps said? I've posted previously an image with hint how it should look like.

@tomkoptel
Copy link

Yep, that helped me :)

At the moment I'm using Android Studio 1.0.2. Also, I've launched studio from console command by launching sh script so that idea could properly pick environment variables.

./your_location/android-studio/bin/studio.sh &

Though the final step was changing JDK location in module settings in Android Studio as suggested @fada21.

@hamidp
Copy link

hamidp commented Jan 23, 2015

For us the issue was a java-library that was part of an Android project. For whatever reason it believed it was jdk 6, and the sdk wasn't around. There definitely should more logging around failures in the plugin itself but we were able to get things running by adding this to the library:

retrolambda {
    javaVersion JavaVersion.VERSION_1_7
}

@hamidp
Copy link

hamidp commented Jan 23, 2015

On top of making sure JAVA_HOME was not set.

@magicgoose
Copy link

I fixed this by changing module's Java SDK path to JDK *8

this thing must be included to README

@hamen
Copy link

hamen commented Feb 6, 2015

Hi all
FYI, It's happening randomly for a couple of weeks now. I can get rid of it only adding

org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home

to my gradle.properties. JAVA_HOME and JAVA8_HOME are properly set too.
Ivan

@dbachelder
Copy link

@hamen thanks, that worked...

@bytehala
Copy link

@magicgoose Your solution worked. Cheers!

@pt2121
Copy link

pt2121 commented Feb 15, 2015

setting org.gradle.java.home works for me.
Thanks @hamen

@alcarvalho
Copy link

For me the only thing that worked was setting adding:

gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

To idea.properties file. In my case it lives here:

/Applications/IntelliJ IDEA 14.app/Contents/bin/idea.properties

And then, restart IntelliJ, obviously.

I have found this here.

I am a Mac OS X (10.9 - Mavericks) user.

If you want to automatically update all your IntelliJs installations, I have made a script to do so here:
https://gist.github.com/alcarvalho/26fb041de96f6cf30e91

Note that if you ever update your jdk 8 version, you should update the file as well.

@evant
Copy link
Owner

evant commented Mar 29, 2015

Sorry for the delay, but I think I got to the bottom to this. The latest version of gradle-retrolambda was compiled with java 8, making it not work if you ran gradle with a lower java version. All the workarounds above ensure that you are running gradle with java 8.

Since my intention was to allow you to run gradle with a lower java version (as long as it can find java 8 to actually compile your source code), this will be fixed in the next version.

@evant
Copy link
Owner

evant commented Mar 31, 2015

Fixed in 3.0.0

@kolipass
Copy link

I have the trable (Unsupported major.minor version 52.0) in fresh version classpath 'me.tatarka:gradle-retrolambda:3.2.3'. What did i do wrong? There is my gist https://gist.github.com/kolipass/ebaa82476a89946e0505 .

I try to use jvmArgs '-noverify' and projectlombok then i have lombok/ast/Node : Unsupported major.minor version 52.0 If i didn't use projectlombok i received java.lang.UnsupportedClassVersionError Unsupported major.minor version 52.0 for every test.

Solution: export JAVA_HOME=$JAVA8_HOME

@TriplEight
Copy link

Also be sure you are not using "Android version to use when rendering layouts in IDE" button with Andriod N (preview) set, choose another version.

@CRomeo8294
Copy link

I solved this by installing Java 8 and changing the JDK location to the new Java 8, rebuilt gradle and everything worked perfectly.

@shantanu-csedu
Copy link

Unset JAVA_HOME and JAVA8_HOME, set JDK8 path in Android studio project settings. Restart android studio if you unset JAVA_HOME while android studio is running.

@lozery
Copy link

lozery commented Aug 19, 2016

@magicgoose
Copy link

magicgoose commented Aug 21, 2016

@lozery

If you're using Eclipse

wait, what? someone does still use it for Android development? why?

@yogieeka
Copy link

Change build gradle version it's work for me
before:
-classpath 'com.android.tools.build:gradle:2.2.0'
after:
-classpath 'com.android.tools.build:gradle:2.1.3'

@ghost
Copy link

ghost commented Oct 3, 2016

I also faced the same problem, it can be solved by following two steps:

Step 1: Download Java 8.
Step 2: Update Android Studio to the latest version 2.2.

@paulirotta
Copy link

Note that current Anndroid tools/google libraries require JDK8 or you will get "Unsupported major.minor version 52.0". This is true even if you are not using Retrolambda.

@ViliusKraujutis
Copy link

Adding this line to gradle.properties file, solved the issue:

org.gradle.java.home=/usr/java/jdk1.8.0_45/

@ghost
Copy link

ghost commented Nov 23, 2016

I met this issue too

@HandokoTjung
Copy link

Go to File --> other setting --> Default project structure... --> check the check box of use embedded jdk
image
cheers^^

@fineday009
Copy link

I was wondering if Java7 works in the issue. It does not work in my win7/JDK1.7, anyone knows?

@realtux
Copy link

realtux commented Nov 5, 2017

For me I just had to restart Android Studio, lol.

@sujeet123
Copy link

Hi All,

I was also facing same issue:
Error:(1, 1) A problem occurred evaluating project ':app'.

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

I just updated JDK location on below setting(from "JDK 1.7" to "C:\Program Files\Android\Android Studio" and select the check box for Embedded JDK).

File->Other Settings=>Default Project Struture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests