cordova Android requirements failed: "Could not find an installed version of Gradle"

I'm trying to build a Cordova Android project using the most recent tools. I followed the instructions here:

$ cordova create myApp com.myCompany.myApp myApp
$ cd myApp
$ cordova platform add [email protected] --save
$ cordova requirements android --verbose

But the result is:

Running command: android list targets
Command finished with error code 0: android list,targets

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-25,android-23
Gradle: not installed 
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 Studio
Error: CordovaError: Some of requirements check failed
    at /usr/local/nodejs_next/lib/node_modules/cordova/src/cli.js:401:45
    at _fulfilled (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:749:13)
    at /usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:557:44
    at flush (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:108:17)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

It doesn't seem to be able to find Gradle (not sure where that's supposed to be).

I've seen reports of issues with Cordova and Android SDK Tools 25.3, but this seems to be different, and I have 25.2.3 (see below).

I have the following (this is on CentOS 6.8):

$ cordova --version
6.5.0

$ node --version
v6.10.2

$ npm --version
3.10.10

$ java -version
openjdk version "1.8.0_121"

$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0

$ echo $ANDROID_HOME
/usr/local/android-sdk

# I installed the Android SDK from here
# https://developer.android.com/studio/index.html#downloads
# under "Get just the command line tools"

$ /usr/local/android-sdk/tools/bin/sdkmanager --list
Installed packages:
  Path                        | Version | Description                    | Location                    
  -------                     | ------- | -------                        | -------                     
  build-tools;23.0.3          | 23.0.3  | Android SDK Build-Tools 23.0.3 | build-tools/23.0.3/         
  build-tools;25.0.2          | 25.0.2  | Android SDK Build-Tools 25.0.2 | build-tools/25.0.2/         
  extras;android;m2repository | 47.0.0  | Android Support Repository     | extras/android/m2repository/
  extras;google;m2repository  | 46      | Google Repository              | extras/google/m2repository/ 
  patcher;v4                  | 1       | SDK Patch Applier v4           | patcher/v4/                 
  platform-tools              | 25.0.4  | Android SDK Platform-Tools     | platform-tools/             
  platforms;android-23        | 3       | Android SDK Platform 23        | platforms/android-23/       
  platforms;android-25        | 3       | Android SDK Platform 25        | platforms/android-25/       
  tools                       | 25.2.3  | Android SDK Tools 25.2.3       | tools/                      

UPDATE:

It doesn't seem to be mentioned anywhere in Cordova's or Android's docs, but if you're using the Android command-line tools without Android Studio, you have to manually install Gradle. Once you do, and it's on your PATH, this error will go away.

An additional thing that was confusing me: in older versions of Android SDK tools, there was a Gradle wrapper script in tools/templates/gradle/wrapper/gradlew. This can also be used to install Gradle, but I found it easier to just install it manually. This seems to have been removed as of the latest version.


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

https://wtanaka.com/node/8079

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

https://gist.github.com/parzonka/9371885

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

If you have android studio installed then you might want to try:

export PATH="$PATH:/home/<username>/android-studio/gradle/<gradle-4.0>/bin" 

This solved my problem.