I am unable to build a gradle project, even if I edit the gradle property, I get the following error:
Error:(22, 1) A problem occurred evaluating root project 'android'. > Failed to apply plugin [id 'android'] > Gradle version 2.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\salangar\angular-cordova-tickrv0.1\platforms\android\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip
How do I resolve this?
I was also getting the same error and modifying the
$(your app path)/platform/android/gradle/wrapper/gradle-wrapper.properties to
didn’t help as it was getting overridden every time i ran cordova build android to 2.2.1
I finally changed the gradleBuilder.js file under $(your app path)/platforms/android/cordova/lib/builders folder.
Search for distributionUrl and change it 2.10.
This triggered download of gradle-2.10 and compilation went through. At least it worked for me.
Instead of manipulating build.js file, the easiet approach would be as follows:
1) Download required gradle version and save it local folder.
2) In command prompt execute the following command:
3) Execute the following command: cordova run android
I discovered the issue here. Android Studio asks to upgrade gradle. Don’t do that ! I’ve made a bug report. The version has to keep being updated in Android Studio after each rebuild on the command line.
File -> Project Structure -> Project. Need to keep changing it to 2.10. There is not one fix for this yet that I’ve seen.
it will always generate same file every times you run build, so the way to handle it find the generator .. in my case App Location> platform > android> cordova >lib> builders> Gradlebuilder.js and find this ..
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\: '
after edit it, every time code generate will create new distribution url you make.
Edit $(your app path)/platform/android/gradle/wrapper/gradle-wrapper.properties:
I use sencha touch 2.4.2 and cordova 5.4.1.
I had the same error because the Sencha-Cmd:
sencha app build native always rewrite the file:
$(your app path)/cordova/platform/android/gradle/wrapper/gradle-wrapper.properties
And reset the variable distributionUrl to the old bad value:
To solve that, i have changed the variable
distributionUrl, directly in the file:
$(your app path)/cordova/platforms/android/cordova/lib/build.js
at line 346 change build.js:
// New good value var distributionUrl = 'distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-all.zip'; // Old bad value // var distributionUrl = 'distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip';
And that permanently solve the problem and i can now have a successful native build for Android 😉