3

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

Community
  • 1
  • 1
Hamed Mahmoudkhani
  • 583
  • 1
  • 6
  • 17
  • Have posted an answer for this question in the following link - http://stackoverflow.com/questions/37349019/error-when-building-a-cordova-android-project/ Please check it out and let me know if it helps – Gandhi May 22 '16 at 05:41
  • Thanks, After this Cordova is downloading lots of JAR file (10m) so prject `built successfully`, I just want to do this solution with Cordova core to every time I dont need to do this and download again... – Hamed Mahmoudkhani May 22 '16 at 07:08
  • Need to check on this. Atleast this solution will avoid gradle download. Should i post this answer? – Gandhi May 22 '16 at 07:14
  • Yepe! , It's solution i just searching for JAR problems... So... – Hamed Mahmoudkhani May 22 '16 at 07:24
  • You can accept the answer if it was helpful so that i can be useful to others too – Gandhi May 22 '16 at 08:06
  • Was the solution helpful? – Gandhi May 25 '16 at 14:01

1 Answers1

7

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

CaptainBli
  • 4,121
  • 4
  • 39
  • 58
Gandhi
  • 11,875
  • 4
  • 39
  • 63