Gradle build failed in unity

Tried updating gradle with new gradle as well as old gradle in unity, still it is showing gradle build failed


CommandInvokationFailure: Gradle build failed. 
/Applications/Unity/Hub/Editor/2021.3.5f1/PlaybackEngines/AndroidPlayer/OpenJDK/bin/java -classpath "/Applications/Unity/Hub/Editor/2021.3.5f1/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

* What went wrong:
String index out of range: 0

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

Do as the output suggests.
Run with --stacktrace to get more information about the exception and where it is coming from.