I was able to reproduce the issue on ubuntu when installing gradle through apt. Even after looking at gradle's source, the cause of the issue is still unclear to me. But it might be related to something in the apt apt package itself.
Indeed, here is a solution that worked for me: instead of installing gradle through apt, install it by downloading from the gradle website, and changing paths accordingly. (you should event remove the apt package with "apt-get remove gradle")
Please try this out and tell us if that works for you as well!