9

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?

gitsitgo
  • 6,589
  • 3
  • 33
  • 45
Smitha
  • 6,110
  • 24
  • 90
  • 161
  • Simple way will be right click on project ->open module settings -> on left click project(below sdk location) ->change gradle version to 2.10.. This will work if you are not manually changing the version anywhere in gradle.. – Sunil Sunny Apr 12 '16 at 07:20
  • @sunil Cordova will overwrite this settings on the next build. You have to tell cordova to use gradle 2.10. I'm still searching for a solution – rickul Jun 03 '16 at 11:59

6 Answers6

22

I was also getting the same error and modifying the
$(your app path)/platform/android/gradle/wrapper/gradle-wrapper.properties to

distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-all.zip

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.

7

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:
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=file:///local/path/to/folder/where/gradle/zip/is/saved/gradle-2.2.1-all.zip

3) Execute the following command: cordova run android

Gandhi
  • 11,875
  • 4
  • 39
  • 63
1

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.

Mostafiz
  • 7,243
  • 3
  • 28
  • 42
Dan Rossi
  • 51
  • 1
  • 4
1

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.

Nissa
  • 4,636
  • 8
  • 29
  • 37
0

Edit $(your app path)/platform/android/gradle/wrapper/gradle-wrapper.properties: find:

distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip

Change to:

distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-all.zip
Yang Tsao
  • 61
  • 1
0

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: distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip

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 ;)

Gandhi
  • 11,875
  • 4
  • 39
  • 63
Cesar Jacquet
  • 45
  • 2
  • 10