gradle-retrolambda icon indicating copy to clipboard operation
gradle-retrolambda copied to clipboard

Unit tests crash with java.lang.UnsupportedClassVersionError with Android build tools 1.3.0

Open paveldudka opened this issue 10 years ago • 7 comments

After updating to the latest Android build tools version, Im not able to run unit tests anymore. Unit test suite throws UnsupportedClassVersionError during test execution.

Steps to reproduce:

  • create new empty project in AS and configure retrolambda (alternatively, I created sample project here, so you can check it out)
  • execute ./gradlew check task to run unit test suite
  • observe test failed with UnsupportedClassVersionError exception

Looking at decompiled .class files in unit test suite, it looks like retrolambda hasn't modified them back to Java7 - bytecode version is listed as 52.0

paveldudka avatar Sep 29 '15 00:09 paveldudka

Looks like it's not forcing the tests to be run with java 8. I'll look into it. In the mean time, you can just run gradle with java 8 and you should be fine.

evant avatar Sep 29 '15 01:09 evant

Thanks! running with JAVA8 did the trick. Looking forward to proper solution

paveldudka avatar Sep 29 '15 01:09 paveldudka

I have the same issue, running gradle with java8 fixed the tests but then it's the assembleDebug which failed. :(

@paveldudka What about you?

tbruyelle avatar Oct 22 '15 09:10 tbruyelle

@tbruyelle had similar issue with one of modules not being able to compile with Java8 - I had to force it to compile in Java7 compatibility mode:

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

paveldudka avatar Oct 22 '15 18:10 paveldudka

@paveldudka wow it works thanks a lot man.

Gradle is definitively the worst unpredictable tool I ever used. My build.gradles are always full of things pasted from everywhere in the Internet. It bothers me so much...

tbruyelle avatar Oct 23 '15 07:10 tbruyelle

@evant any progress on this? @paveldudka's fix didn't work for me. :(

ubuntudroid avatar Nov 02 '15 12:11 ubuntudroid

May I ask how do you run with JAVA8? I tried setting org.gradle.java.home in gradle.properties but that doesn't work. No matter what I change UnitTest always run using JAVA7.

Ok, I had to change project JDK Location in Project Structure.

RobGThai avatar Nov 02 '15 12:11 RobGThai