Need help on "A problem occurred starting process 'Gradle build daemon'

I am trying to build a Flutter project and I am stuck on this error for quite a while now. When I try to run the command “flutter --no-color build apk”, it fails with the above message. It gives no details as to why it failed. The weird thing is I am able to build the APK by executing the command “gradlew build”. However, running flutter build apk is important to debug from Android Studio/VS Code.

I have already tried multiple things such as using latest gradle version, cleaning caches, reinstalling flutter and so on ( ) but nothing is working and I am at my wits end. I am close to throwing and burning my machine. I don’t know wtf is going on.

Is there any way to find out what exactly is the problem?
thank you.