Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

android - 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:Androidsdk

JAVA_HOME=C:Program FilesJavajdk1.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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...