Install gradle for using in cordova build android

前端 未结 2 1869
无人及你
无人及你 2020-12-08 08:40

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

相关标签:
2条回答
  • 2020-12-08 09:01

    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.

    0 讨论(0)
  • 2020-12-08 09:02

    Window, Linux & MacOS users - Install Gradle manually


    Step 1. Download the latest Gradle distribution

    Step 2. Unpack the distribution Create a new directory C:\Gradle with File Explorer.

    Open a second File Explorer window and go to the directory where the Gradle distribution was downloaded. Double-click the ZIP archive to expose the content. Drag the content folder gradle-[VERSION] to your newly created C:\Gradle folder.

    Alternatively you can unpack the Gradle distribution ZIP into C:\Gradle using an archiver tool of your choice.

    Step 3. Configure your system environment

    • Linux & MacOS users

    Configure your PATH environment variable to include the bin directory of the unzipped distribution, e.g.:

     $ export PATH=$PATH:/opt/gradle/gradle-4.1/bin
    

    • Microsoft Windows users

    In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables.

    Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-4.1\bin. Click OK to save.

    Step 4. Verify your installation

    Open a console (or a Windows command prompt) and run below command to run Gradle and display the version, e.g.:

    gradle -v
    

    OutPut

    Microsoft Windows [Version 10.0.14393]
    (c) 2016 Microsoft Corporation. All rights reserved.
    
    C:\Users\rupesh.a.yadav>gradle -v
    
    ------------------------------------------------------------
    Gradle 4.1
    ------------------------------------------------------------
    
    Build time:   2017-08-07 14:38:48 UTC
    Revision:     941559e020f6c357ebb08d5c67acdb858a3defc2
    
    Groovy:       2.4.11
    Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
    JVM:          1.8.0_144 (Oracle Corporation 25.144-b01)
    OS:           Windows 10 10.0 amd64
    
    C:\Users\rupesh.a.yadav>
    

    Read - For More

    Hope this will be a help for all! :)

    0 讨论(0)
提交回复
热议问题