Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Java error "Unsupported class file major version 63"

Tags:

java

flutter

"General error during conversion: Unsupported class file major version 63"

I've tried multiple suggestions on here. None have worked. I think I need more of a step-by-step solution because I've tried installing multiple versions of Java (19,16,11), flutter clean, flutter doctor is all good, and I've installed a newer version of Android Studio (just in case). Here is what I see in VSCode:

enter image description here

enter image description here

like image 708
tazboy Avatar asked Nov 01 '25 01:11

tazboy


2 Answers

I encountered this error while trying to run Flutter integration tests on Firebase Test Lab. I was able to solve this by updating a few things in Android Studio.

Update the Project's JDK

Open the Android Studio project settings page (File -> Project Settings) and add the newest JDK version.

enter image description here

Update com.android.tools.build:gradle

In android/build.gradle, update the com.android.tools.build:gradle value to the latest version found here.

 dependencies {
        classpath 'com.android.tools.build:gradle:7.4.1'
        ...
    }

Update the gradle distributionUrl

In android/gradle/wrapper/gradle-wrapper.properties, update the distributionUrl property to use the latest Gradle version.

distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip

Other Useful Tips

  • You can type /usr/libexec/java_home into the terminal to see which version of Java you have installed.

  • You can find the current value of JAVA_HOME by running %echo $JAVA_HOME in your terminal (source).

  • You can update JAVA_HOME by following these steps

like image 153
Joe Muller Avatar answered Nov 03 '25 17:11

Joe Muller


The problem is that somehow, either deliberately or inadvertently, you've built one or more Java files (or you're using one or more 3rd party .jars) with Java 19 ... but your "build environment" is using an older JRE. Hence the Unsupported class file error.

I, too, am using VSCode for my Flutter IDE; and I, too have Android Studio in my environment. Unfortunately, there are constantly new releases for Flutter, for VSCode, for the Android SDK, for Android Studio (with its own embedded Java/Kotlin!) and - last, but not least - for Gradle and the A/S Gradle plugin. Any one of them falling out of sync can break your entire development environment :(

I just tried to rebuild a project that compiled fine a few months ago... and (as expected) the build failed. None of the source change - but I recently upgraded A/S, and that inadvertently broke the Flutter build :(

SUGGESTION:

  1. See if you can identify which Java class or .jar is using Java 19 ... and back it down to an older version.

  2. In parallel, upgrade EVERYTHING in your build environment:

    • flutter upgrade => Flutter 3.7.3, Dart 2.19.2

    • VSCode update, pub upgrade => VSCode 1.751, Dart Code 3.58.0

    • A/S upgrade => Electric Eel 2022.1.1 Patch 1, Gradle Plugin 4.2.2

      Note: Gradle Plugin 4.2.2 => Gradle version => 6.7.1, Default=Java8, AGP dependency 4.2.2

    • A/S Electric Eel gives you java 11... in (new!) directory "c:\Program Files\Android\Android Studio\jbr"

like image 37
paulsm4 Avatar answered Nov 03 '25 17:11

paulsm4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!