skip to Main Content

I encountered an issue while building my Flutter project with Gradle. The build failed with the following error message:

FAILURE: Build failed with an exception.

* What went wrong:
Could not open settings generic class cache for settings file '/Users/mishalhaneef/Documents/flutter/Zartek/blind_crushes/android/settings.gradle' (/Users/mishalhaneef/.gradle/caches/7.4.1/scripts/a7jtzc7d8e1ht64fuhmylehgj).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 64

* 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 1m 8s
┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project's Gradle version is incompatible with the Java version that Flutter is using    │
│ for Gradle.                                                                                      │
│                                                                                                  │
│ 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/mishalhaneef/Documents/flutter/Zartek/blind_crushes/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                                │
2
│                                                                                                  │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

I’m using Flutter for my project, and it seems that there is a compatibility issue between the Gradle version used and the required Java version.

I have already checked the Java version used by Flutter by running flutter doctor –verbose and noted the version displayed. I also updated the Gradle version in gradle-wrapper.properties to be compatible with the Java version.

Despite these steps, the error persists. I tried running the build with --stacktrace for a more detailed trace, as well as using --info and --debugoptions for additional log output, but it didn’t provide further insights.

2

Answers


  1. In ‘android/gradle/wrapper/gradle-wrapper.properties’
    Change distributionUrl

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

    In ‘android/build.gradle’,
    Change ‘com.android.tools.build:gradle:****’ to

    ‘com.android.tools.build:gradle:7.2.1’

    Login or Signup to reply.
  2. Try to update your gradle version to higher one.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search