Maybe this will help with someone having a similar,but not exact, issue as OP's. that come across this post when searching for solution.
I had a similar problem on Linux system when trying to build a Kotlin project using Gradle Wrapper. I eventually traced problem to that months back I was building using a local install of gradle rather than gradlew. When I started using gradlew, I removed the local Gradle install, but forgot that I had put a PATH variable in my .bashrc file that referenced the local Gradle install.
Once I removed the PATH variable setting in the .bashrc file, the gradlew build and run worked fine.
If I understand correctly, if the build process detects a reference to a local install it will override the wrapper method and attempt to use a local Gradle process (and its javatool chain references, etc) for the build.