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.