Solution for linux with apt-get (eg.: Ubuntu, Debian)
I have quite similar problem. I obtained error:
Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studi
but without Exception. I solved it on Ubuntu by
sudo apt-get install gradle
I found also commands that allows install newest version of gradle in Ubuntu. It works only when first command is executed before (probably some dependecies are incorrect).
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle-ppa
If it does not work, try:
export PATH=$PATH:/opt/gradle/gradle-3.5/bin
More info:
https://askubuntu.com/questions/915980/package-is-installed-and-is-not-detected-gradle/915993#915993
For CentOS
Instruction of instalation gradle
for CentOS is under this link
Update
Now I installing gradle by sdkman it is something like nvm for node.
Install sdkman
curl -s "https://get.sdkman.io" | bash
Install gradle
sdk install gradle 4.0.2