Exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 66

While running the “./gradlew signingRepor”, I having this issue, can I know why?

PS C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android> ./gradlew signingReport                                                                                          

* Where:
Settings file 'C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android\settings.gradle' line: 20
   > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 66

* 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 728ms

Because you are using Java 22 to run Gradle which is up-to-now not supported in any version: Compatibility Matrix

After downgrade the Java 22 to Java 21, I still facing another problem Sir…

PS C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android> ./gradlew signingReport
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
Could not open cp_settings generic class cache for settings file 'C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android\settings.gradle' (C:\Users\wongp\.gradle\caches\7.5\scripts\32f6x2crux44vvqu2c7rxfaj9).
> 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 21s

Because you are using Java 21 to run Gradle 7.5 which is not supported: Compatibility Matrix

After using java 18 & gradle 7.5, the more problem occur,why?

PS C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android> ./gradlew signingReport
Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply


FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android\build.gradle' line: 13

* What went wrong:
Could not compile build file 'C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android\build.gradle'.
> startup failed:
  build file 'C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android\build.gr
adle': 13: all buildscript {} blocks must appear before any plugins {} blocks in the script

  See https://docs.gradle.org/7.5/userguide/plugins.html#sec:plugins_block for information on the plugins {} block

   @ line 13, column 1.
     buildscript {
     ^

  1 error


* 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 13s

Gradle 7.5
------------------------------------------------------------

Build time:   2022-07-14 12:48:15 UTC
Revision:     c7db7b958189ad2b0c1472b6fe663e6d654a5103

Kotlin:       1.6.21
Groovy:       3.0.10
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          18.0.2.1 (Oracle Corporation 18.0.2.1+1-1)
OS:           Windows 11 10.0 amd64

PS C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android> java --version
java 18.0.2.1 2022-08-18
Java(TM) SE Runtime Environment (build 18.0.2.1+1-1)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing)

The error message is quite clear, isn’t it?
Which part do you not understand?

so far i still have a bit error here…

PS C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android> ./gradlew signingReport                                                                                  

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\wongp\Music\E-commerce-Complete-Flutter-UI-master\android\build.gradle' line: 58

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method implementation() for arguments [DefaultExternalModuleDependency{
group='com.google.firebase', name='firebase-bom', version='32.8.1', configuration='defau
lt'}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* 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 1s
4 actionable tasks: 4 up-to-date

If i remove the below command from the andriod/build.gradle, it able to generate the SHA, but if i added these 2 command there will be an error

dependencies {
    // Import the BoM for the Firebase platform
       implementation(platform("com.google.firebase:firebase-bom:32.8.1"))

    // Add the dependency for the Firebase Authentication library
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation("com.google.firebase:firebase-auth")
}

If you get that error, it means you did not apply any plugin that adds this configuration named implementation to which you try to add dependencies.

Btw. I highly recommend you use Kotlin DSL instead. By now it is the default DSL, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.