79104598

Date: 2024-10-19 09:35:15
Score: 0.5
Natty:
Report link

I recently updated my Android Studio and Flutter, and I started experiencing the same issue.

flutter run
Launching lib\main.dart on SM F415F in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Could not open cp_settings generic class cache for settings file 'PROJECT\android\settings.gradle' (C:\Users\Claudio\.gradle\caches\7.6.3\scripts\gmzea7a38jwwtj6757fg97wu).
> 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 997ms
Running Gradle task 'assembleDebug'...                           1.739ms

┌─ 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 PROJECT\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

Apparently, even though I had JAVA_HOME configured in the environment variables, Android Studio was running its own Java, installed on another path.

$ java --version
java 17.0.12 2024-07-16 LTS
Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.12+8-LTS-286, mixed mode, sharing)

$ flutter doctor --verbose
[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [versÆo 10.0.19045.5011], locale pt-BR)
    • Flutter version 3.24.3 on channel stable at C:\Workspace\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (5 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Workspace\android\android-sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = C:\Workspace\android\android-sdk
    • Java binary at: C:\Users\Claudio\AppData\Local\Programs\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2024.2)
    • Android Studio at C:\Users\Claudio\AppData\Local\Programs\Android Studio
    • 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+-12282718-b509.11)

[√] Connected device (4 available)
    • SM F415F (mobile) • RQ8R503THDB • android-arm64  • Android 12 (API 31)
    • Windows (desktop) • windows     • windows-x64    • Microsoft Windows [versÆo 10.0.19045.5011]
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 130.0.6723.59
    • Edge (web)        • edge        • web-javascript • Microsoft Edge 130.0.2849.46

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

JAVA_HOME is set to "C:\Program Files\Java\jdk-17," and Flutter doctor displays "• Java binary at: C:\Users\Claudio\AppData\Local\Programs\Android Studio\jbr\bin\java."

The solution was to manually configure the JDK for Flutter:

$ flutter config --jdk-dir="C:\Program Files\Java\jdk-17"
Setting "jdk-dir" value to "C:\Program Files\Java\jdk-17".

Only then did the problem stop.

$ flutter doctor --verbose
[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [versÆo 10.0.19045.5011], locale pt-BR)
    • Flutter version 3.24.3 on channel stable at C:\Workspace\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (5 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Workspace\android\android-sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = C:\Workspace\android\android-sdk
    • Java binary at: C:\Program Files\Java\jdk-17\bin\java
    • Java version Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2024.2)
    • Android Studio at C:\Users\Claudio\AppData\Local\Programs\Android Studio
    • 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+-12282718-b509.11)

[√] Connected device (4 available)
    • SM F415F (mobile) • RQ8R503THDB • android-arm64  • Android 12 (API 31)
    • Windows (desktop) • windows     • windows-x64    • Microsoft Windows [versÆo 10.0.19045.5011]
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 130.0.6723.59
    • Edge (web)        • edge        • web-javascript • Microsoft Edge 130.0.2849.46

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Reasons:
  • Blacklisted phrase (1): the link below
  • RegEx Blacklisted phrase (1): See the link
  • Long answer (-1):
  • Has code block (-0.5):
Posted by: calraiden