Having a "CommandInvokationFailure: Gradle build failed. " When building apk

Whenever I try to build the apk for the game I get this error
“CommandInvokationFailure: Gradle build failed.
C:\Unity\2022.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Unity\2022.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.2.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleDebug””

  • What went wrong:
    Execution failed for task ‘:unityLibrary:compileDebugJavaWithJavac’.

Compilation failed; see the compiler error output for details.

  • 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.