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

[Flutter] Flutter build error: "invalid source release: 17" when building app bundle

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

  1. Stack

    Stack Membro Participativo

    I'm encountering an issue while trying to build an Android app bundle (appbundle) for release in my Flutter project on Android studio. I'm getting the following error message:

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':package_info_plus:compileReleaseJavaWithJavac'.
    > error: invalid source release: 17


    Here's some details of my setup:

    Java Home:

    /usr/libexec/java_home -V

    Matching Java Virtual Machines (3):
    20.0.1 (x86_64) "Oracle Corporation" - "Java SE 20.0.1" /Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home
    17.0.2 (x86_64) "Oracle Corporation" - "OpenJDK 17.0.2" /Users/user/Library/Java/JavaVirtualMachines/openjdk-17.0.2/Contents/Home
    1.8.391.13 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    /Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home


    Environment Configuration (echo $JAVA_HOME):

    /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home


    Flutter Version:

    flutter --version
    Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision 54e66469a9 (2 days ago) • 2024-04-17 13:08:03 -0700
    Engine • revision c4cd48e186
    Tools • Dart 3.3.4 • DevTools 2.31.1


    Android Project Configuration (android/app/build.gradle):

    android {
    compileSdkVersion 34
    android {
    ndkVersion "25.2.9519653"
    }

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
    jvmTarget = '1.8'
    }
    }


    I have been facing this issue after upgrading to macOS Sonoma 14.4.1, and I'm using an M3 Mac.

    I've tried various solutions from stack overflow Execution Failed for task :app:compileDebugJavaWithJavac in Android Studio

    Could someone please provide guidance on how to resolve this issue? Any insights or suggestions would be greatly appreciated.

    Continue reading...

Compartilhe esta Página