I got an email from Google asking me to update Fit Cat for Android Wear 2.0, so I tried to compile that after I haven’t touched it for a few months.

Since Studio evolves so quickly, I wasn’t exactly surprised when I got an error:

square island: java compatibility in build.gradle - Java 1 7 - Square Island: Java compatibility in build.gradle
Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been
compiled using  8 or above.

It asked me to add sourceCompatitbility and targetCompatitbility to Java submodules. What does that mean? After a lot of searching plus trial and error I found the answer.

In your -level build.gradle, add this:

allprojects {
  tasks.withType(JavaCompile) {
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7

Source link


Please enter your comment!
Please enter your name here