Unit tests crash with java.lang.UnsupportedClassVersionError with Android build tools 1.3.0
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 checktask 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
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.
Thanks! running with JAVA8 did the trick. Looking forward to proper solution
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 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 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...
@evant any progress on this? @paveldudka's fix didn't work for me. :(
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.