0

I'm trying to update my gradle file to work with version 2.2.3. However, I get the following error when building:

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

As far as I know, it's related to Java 8. My code is targeting Java 7 as I can't update to Java 8 because the Jack compiler makes a lot of other problems I can't deal right now.

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

I guess what I should do is to target JAVA 7 but compile against JAVA 8.

enter image description here

And it seems that the path in the window above does direct to Java 8.

enter image description here

How I get over this??

Rom Shiri
  • 1,390
  • 4
  • 16
  • 29
  • Are you using any 3rd party dependencies that are compiled against Java 8? – Egor Jan 03 '17 at 16:24
  • No. It happens even if I create a new project with no other special dependencies – Rom Shiri Jan 03 '17 at 16:28
  • what give : `gradlew --version` (or `gradle --version`) – dwursteisen Jan 03 '17 at 16:30
  • Gradle 2.14.1, JVM 1.7.0_79 (Oracle Corporation 24.79-b02) Guess this is the problem - how can I make it work with JVM 1.8? Even when I update my "sourceCompatibility" and "targetCompatibility" to 1.8 I still get this values and the above error. – Rom Shiri Jan 03 '17 at 16:37
  • Don't confuse the Java Gradle runs against with the source- and targetCompatibility of your sourcecode. If you run Gradle with Java 1.8 and say targetCompatibility 1.7, your code will still run on 1.7, but Gradle uses 1.8 to run. The error you get means that you use some class compiled for 1.8 in an 1.7 run. In your case you run Gradle with Java 1.7, but the Android plugin you use is compiled against Java 1.8. – Vampire Jan 03 '17 at 17:14
  • My project is just a new one I've just created with Android Studio. Do I need to change something in my environment to get over this? – Rom Shiri Jan 04 '17 at 09:26
  • you can try add java path settings to gradle. something like this: org.gradle.java.home=C:/Program Files/Java/jdk1.8 https://discuss.gradle.org/t/how-to-change-java-home-using-gradle-proeprties/5649/2 – BlackRainbow Feb 07 '17 at 11:19

0 Answers0