Cordova / Ionic build android Gradle error: Minimum supported Gradle version is 2.14.1. Current version is 2.13 : <p>This is a solution to the above error that I want to document.  I found other similar posts, but none described how this error can be associated with Cordova or Ionic.</p>

<p>If you are not careful, there can be a mismatch between the version of Gradle that Android Studio uses and the version of Gradle that Cordova / cordova-android specifies in its auto-generated application code.  As you know, running</p>

<pre><code>$ cordova platform add android
</code></pre>

<p>(or <code>$ ionic platform add android</code>, if you are building an Ionic app) creates  the native application code at the-project/platforms/android.  </p>

<p>Inside that folder, the file: /the-project/platforms/android/cordova/lib/builders/GradleBuilder.js exports a variable as shown below:</p>

<pre><code>var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-x.y-all.zip';
</code></pre>

<p>Where x and y depened on which version of Cordova / cordova-android are being used to build the native application code.  </p>

<p>When you run</p>

<pre><code>$ cordova build android
</code></pre>

<p>The version of Gradle specified in the <code>distributionUrl</code> var is the version used for the build.</p>

<p>Now here comes the tricky part.  When you import the project into Android Studio, you will most likely get a message strongly recommending that you upgrade Gradle to a newer version, as shown below:  </p>

<p><a href="https://i.stack.imgur.com/N1ytd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/N1ytd.png" alt="enter image description here"></a>
If you do this, Android Studio will download a new version of Gradle and store it locally and configure the project to use the newly download local Gradle distribution, which is the radio option below the selected “Use default grade wrapper”, which I ended up deselecting because this will cause errors.</p>

<p><a href="https://i.stack.imgur.com/geQN9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/geQN9.png" alt="enter image description here"></a> </p>

<p>This will cause problems because Android Studio and Cordova will now be attempting to build the application with different versions of Gradle and you will get build errors within Android Studio and also with </p>

<pre><code>$ cordova build android
</code></pre>

<p>in the command line.  The solution with Cordova apps is to always keep the Android Studio project set to "Use default gradle wrapper" and ignore the tempting messages to upgrade.  If you do want to use a newer version of Gradle, you can always change the distributionUrl var in the file mentioned above (however Cordova strongly discourages modifying code within the platforms folder since it is easily overwritten).  At the time of writing this, I cannot tell is there is a way to set the Gradle version at the </p>

<pre><code>$ cordova platform add android
</code></pre>

<p>step, which is when you would want to do it so you are never directly modifiying code inside of the-project/platforms</p>
