Minimum supported Gradle version is 4.1. Current version is 3.3

I had the same problem with cordova.

You need to edit the gradle version to the latest in these files.

platforms/android/app/build.gradle
platforms/android/cordova/lib/builders/GradleBuilder.js
platforms/android/cordova/lib/builders/StudioBuilder.js
platforms/android/build.gradle

While I am writing this post, the latest version is a 4.10.2. Current versions can be found here.

In /android/app/build.gradle find this part of the code.

task wrapper(type: Wrapper) {
    gradleVersion = '4.10.2'
}

In GradleBuilder.js find this part of the code.

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.10.2-all.zip';

In StudioBuilder.js find this part of the code.

  var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.10.2-all.zip';

In last file /android/build.gradle we change the following line to actual version. Actual version for Android Gradle plugin you can find on this side.

classpath 'com.android.tools.build:gradle:3.1.2'

Thanks Khaled Osman


I got the solution for my problem after trying so many alternatives and i.e.

For those who use ionic, go to

[project name]/platforms/android/cordova/lib/builders/GradleBuilder.js 

on line 164 you will see the following:

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.13-all.zip';

This line is used to create your gradle-wrapper.properties, so any changes to the gradle-wrapper.properties won't matter. All you need to do is change the url to the latest version, sync the gradle and the problem is solved.

If you just want to change the gradle version in the Android studio, go to File>settings>project and change the gradle version. After you apply, it will sync the project and you are ready to build.

Tags:

Android

Maven