Android assembleRelease Failed with Error: Unsupported class version number [53.0] (maximum 52.0, Java 1.8)

4.9k Views Asked by At
  • Android Studio 4.0.1
  • gradle-wrapper.properties: distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
  • build.gradle:
dependencies {
    classpath "com.android.tools.build:gradle:3.0.0"
    
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

When assembling the release apk, it fails with an error:

Warning: Exception while processing task java.io.IOException: Can't read [C:\Users\derek_y\AppData\Local\Android\Sdk\platforms\android-30\android.jar] (Can't process class [android/annotation/Nullable.class] (Unsupported class version number [53.0] (maximum 52.0, Java 1.8))) :app:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

Why is android-30\android.jar requiring Java version 53.0 (Java 9)? Android Studio 4.0.1 is not supporting Java 9 right?

P.S. I tried

  • gradle-wrapper.properties: distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip
  • build.gradle:
dependencies {
    classpath "com.android.tools.build:gradle:4.0.1"
    
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

But then running the compiled apk triggered another error which is from a third-party SDK:

java.lang.VerifyError: Rejecting class a.b.c because it failed compile-time verification

I want a quick fix, and requesting the third-party to update takes time, so this is not helping at this moment. Or anyone could explain why this VerifyError occur and how to fix it?

Thank you a lot.

1

There are 1 best solutions below

0
On

This looks like an issue in the Android Gradle Plugin (issue 77587908). It was fixed in AGP 3.3.0.

Try upgrading AGP to 3.3.0 instead of 4.0.1:

classpath "com.android.tools.build:gradle:3.3.0"

This might be enough to fix your problem without introducing additional issues.