Reputation: 603
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
Upvotes: 3
Views: 5621
Reputation: 11935
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
Upvotes: 7