Gradle build Problem: FAILURE: Build failed with an exception

After Gradle Upgradation we are getting below exception and build failed.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:mergeDebugShaders'.
   > Cannot use @TaskAction annotation on method IncrementalTask.taskAction$gradle_core() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Cannot invoke "com.android.builder.model.BuildType.getName()" because "this.buildType" is null

* 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.
==============================================================================

Please share any reference build.gradle file for latest gradle version

I guess the Android Gradle Plugin verison you use is not compatible with the Gradle version you upgraded to. The IncrementalTaskInputs class that is mentioned in your error was deprecated in Gradle 7.4 and removed in Gradle 8.0.

Typically you should just upgrade to the latest patch version within the same major version, then fix all deprecation warnings, then upgrade to the latest patch version within the next major version, then again fix all deprecation warnings and so on. And on the way you should consider the upgrade notes in the userguide.

This usually cares for a smooth upgrade experience.