flutter / website

Flutter documentation web site
https://docs.flutter.dev
Other
2.83k stars 3.24k forks source link

Gradle JDK compatibilities issues provided documentation missing / not complete concrete information #11373

Open zakblacki opened 2 weeks ago

zakblacki commented 2 weeks ago

Page URL

https://docs.flutter.dev/release/breaking-changes/android-java-gradle-migration-guide/

Page source

https://github.com/flutter/website/tree/main/src/content/release/breaking-changes/android-java-gradle-migration-guide.md

Describe the problem

Complete details logs :

Note : I have also applied flutter clean then flutter pub get and invalidated caches IDE and removed caches gradle as well. Note 2 : Tried both gradle 7.6.1 and 7.6.4 and downgrading JDK to 17 or 19 is not a solution either

Launching lib/main.dart on M2101K6G in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Could not open cp_settings generic class cache for settings file '/Users/g-besoin/Desktop/listar/android/settings.gradle' (/Users/g-besoin/.gradle/caches/7.6.1/scripts/18gspo718l4kt06o9u3za2lj4).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 594ms

┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project's Gradle version is incompatible with the Java version that Flutter is using    │
│ for Gradle.                                                                                      │
│                                                                                                  │
│ If you recently upgraded Android Studio, consult the migration guide at                          │
│ https://flutter.dev/to/to/java-gradle-incompatibility.                                           │
│                                                                                                  │
│ Otherwise, to fix this issue, first, check the Java version used by Flutter by running flutter  │
│ doctor --verbose.                                                                               │
│                                                                                                  │
│ Then, update the Gradle version specified in                                                     │
│ /Users/g-besoin/Desktop/listar/android/gradle/wrapper/gradle-wrapper.properties to be compatible │
│ with that Java version. See the link below for more information on compatible Java/Gradle        │
│ versions:                                                                                        │
│ https://docs.gradle.org/current/userguide/compatibility.html#java                                │
│                                                                                                  │
│                                                                                                  │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1

My flutter version :

[✓] Flutter (Channel stable, 3.24.4, on macOS 15.1 24B83 darwin-arm64, locale
    en-DZ)
    • Flutter version 3.24.4 on channel stable at
      /Users/g-besoin/Downloads/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 603104015d (2 weeks ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/g-besoin/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/g-besoin/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/g-besoin/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Android Studio (version 2024.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

My JDK version :

java 23.0.1 2024-10-15
Java(TM) SE Runtime Environment (build 23.0.1+11-39)
Java HotSpot(TM) 64-Bit Server VM (build 23.0.1+11-39, mixed mode, sharing)

My gradle-wrapper.properties :

distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip My settings.gradle :

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version '7.4.2' apply false
    id "org.jetbrains.kotlin.android" version "1.9.25" apply false
    id "com.google.gms.google-services" version "4.4.2" apply false
    id "com.google.firebase.crashlytics" version "2.9.9" apply false
}

This issue raised after migrating last version flutter and IDE on mac

Android Studio Ladybug | 2024.2.1 Patch 2 Build #AI-242.23339.11.2421.12550806, built on October 24, 2024 Runtime version: 21.0.3+-79915917-b509.11 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Toolkit: sun.lwawt.macosx.LWCToolkit macOS 15.1 GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation Memory: 2048M Cores: 8 Metal Rendering is ON Registry: ide.experimental.ui=true i18n.locale= terminal.new.ui=true Non-Bundled Plugins: Dart (242.22855.32) io.flutter (82.1.3)

image

Expected fix

No response

Additional context

No response

I would like to fix this problem.

sfshaza2 commented 2 weeks ago

@parlough, this was an issue in Flutter 3.10, a long time ago. Do you have any idea if this is still relevant?