Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Sync Gradle with Apache Cordova

I installed Apache Cordova on my pc and everything is fine but...

when i try to build every project... (in Command Line Interface) cordova is trying to download Gradle...

Command Prompt Output :


ANDROID_HOME=C:\Android\sdk

JAVA_HOME=C:\Program Files\Java\jdk1.8.0_92

Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip

but i already installed gradle and added it to system path variables...

Note : I can import project into android studio and build it..

I just need to sync mine Gradle to ApacheCordova and build it

Thanks

like image 442
Hamed Mahmoudkhani Avatar asked Nov 23 '25 11:11

Hamed Mahmoudkhani


1 Answers

To avoid gradle download for each build, you may follow the workaround as follows:

1) Download the required gradle version zip file from gradle distribution link and save it in local folder.

2) Navigate to PROJECT_ROOT_FOLDER/platforms/android/cordova/lib/builders folder and edit GradleBuilder.js file

3) Change the line from: var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip';

to 

'var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'file:///local/path/to/folder/where/gradle/zip/is/saved/gradle-2.2.1-all.zip'; 
and save the file

4) Try rebuilding android build.

You can also try the following as quick fix,

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

2) Execute the following command: cordova run android

like image 190
Gandhi Avatar answered Nov 26 '25 01:11

Gandhi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!