Nasser Mansouri
Nasser Mansouri

Reputation: 750

Install gradle for using in cordova build android

I have installed cordova and android sdk on linux mint 17, and downloaded gradle 2.4 (bin) and extracted it and set path to it, now I can get gradle -v from terminal, its ok, but when i want to build cordova :

cordova build

it starts to download gradle 2.2....

how i can set it to use current gradle 2.4 insteed downloading older version?

gradle -v

------------------------------------------------------------
Gradle 2.4
------------------------------------------------------------

Build time:   2015-05-05 08:09:24 UTC
Build number: none
Revision:     5c9c3bc20ca1c281ac7972643f1e2d190f2c943c

Groovy:       2.3.10
Ant:          Apache Ant(TM) version 1.9.4 compiled on April 29 2014
JVM:          1.7.0_79 (Oracle Corporation 24.79-b02)
OS:           Linux 3.13.0-24-generic i386

Upvotes: 22

Views: 48822

Answers (1)

btpka3
btpka3

Reputation: 3830

I had figured out the reason:
See the code GradleBuilder.prototype.prepEnv in $PROJECT_ROOT/platforms/android/cordova/lib/builders/GradleBuilder.js

A quick fix :

export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=file:///local/path/to/gradle-2.4-all.zip
cordova run android

Notice:

  1. This will unzip to $USER_HOME/.gradle/wrapper/dists/gradle-2.4-all/5i28vc5j9c3ssbtreg4518ujvp/gradle-2.4 .
  2. export command must always be executed before run cordova.

If the network is slow, you download gradle-2.2.1-all.zip manually, then use this method once.

Also, you can change GradleBuilder.js's code or request a enhancement/issue.

Upvotes: 17

Related Questions