1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Gradle Build Fails with "Unsupported class file major version 65" After Updating to...

Discussão em 'Mobile' iniciado por Stack, Outubro 9, 2024 às 08:22.

  1. Stack

    Stack Membro Participativo

    I’m working on a Flutter project and recently updated to Java 17. Since the update, my build fails with the following error when trying to run assembleDebug:

    FAILURE: Build failed with an exception.

    • What went wrong: Could not open cp_settings generic class cache for settings file '.../android/settings.gradle'.

    BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 65

    It seems to be related to Gradle and Java compatibility. I’ve already tried updating the gradle-wrapper.properties to a Gradle version that supports Java 17, but the error persists. Here's what I’ve done so far:

    Updated gradle-wrapper.properties to use Gradle version 7.3.3:

    distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip Ensured Java 17 is installed and set as the default JAVA_HOME on my system.

    Flutter doctor output confirms that Flutter is using Java 17.

    Despite these steps, the build continues to fail. Here's the full error output:


    BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 65

    Steps I’ve Tried: Updating Gradle to 7.3.3 in gradle-wrapper.properties. Running flutter clean and rebuilding the project. Ensuring JAVA_HOME is pointing to the correct Java 17 installation. Environment: Flutter version: (specific version) Java version: 17 Gradle version: 7.3.3 (set in gradle-wrapper.properties)

    This is my build.gradle code

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
    jvmTarget = '17'
    }


    P.S. All of this started when i updated Android Studio to the Ladybug version

    Continue reading...

Compartilhe esta Página