Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to build an android gradle project - for a cordova project

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?

like image 984
Smitha Avatar asked Apr 12 '16 07:04

Smitha


People also ask

Does Cordova need Android studio?

Cordova-Android requires the Android SDK, which can be installed on either macOS, Linux, or Windows. For the base system requirements, see the Android Studio's System Requirements.

Why is my gradle not syncing?

Resolution is simple. Open the "Android SDK Manager", update all packages and then restart your Android Studio. After that you project should compile without any issues.


2 Answers

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.

like image 200
Kamal Maheshwari Avatar answered Oct 05 '22 15:10

Kamal Maheshwari


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

like image 27
Gandhi Avatar answered Oct 05 '22 15:10

Gandhi