android studio 1.2 gradle is very slow

前端 未结 5 1580
长情又很酷
长情又很酷 2020-12-04 15:37

it\'s been a while that I\'m using Android Studio, and up until now I was using 1.0.1, gradle was a bit slow, around 1.5 minute for assembleDebug (my project is really big!

相关标签:
5条回答
  • 2020-12-04 16:03

    The reason could be multiDex,

    turn multiDexEnabled to false in your build.gradle file (for debug only, keep it for release).

    android {
    ...
        defaultConfig {
            ...
            multiDexEnabled false
            ...
        }
    }
    

    In addition you should consider to use the lastest version (2.4 at the moment) by editing the gradle-wrapper.properties file and set gradle-2.4-all.zip

    distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
    

    What is MultiDex : https://developer.android.com/tools/building/multidex.html

    0 讨论(0)
  • 2020-12-04 16:10

    From settings go to HTTP connection and disable any proxy and you will find speed you want

    0 讨论(0)
  • 2020-12-04 16:15

    I was testing my app with Google+ log in. So I added release signing to debug version. App compiling in ~ 26 seconds.

    build.gradle Module: app file

    signingConfigs {
        debug {
            storeFile file(project.property("MyApp.signing"))
            storePassword project.property("MyApp.signing.password")
            keyAlias project.property("MyApp.signing.alias")
            keyPassword project.property("MyApp.signing.password")
        }
    }
    

    When I remove that ~ 7.5 seconds.

    Next I tested offline grade

    File - Settings - Build, Execution... - Build Tools - Gradle - Offline work

    Now my app compiling in ~ 4.5 seconds.

    Of course I also added turn on - Compile independent modules in parallel (may require larger heap size) - Make project automatically (only works while not running / debugging)

    File - Settings - Build, Execution... - Compiler

    0 讨论(0)
  • 2020-12-04 16:16

    had the same problem.

    What I did was to change the global gradle settings to offline work which can be done by going to Preferences => Gradle. This did make a difference.

    Another method I have seen people use, but which I have not used yet is to create a gradle.properties in the gradle folder like so:

    Just create a file named gradle.properties in the following directory:

    /home/<username>/.gradle/ (Linux)
    /Users/<username>/.gradle/ (Mac)
    C:\Users\<username>\.gradle (Windows)
    

    Add this line to the file:

    org.gradle.daemon=true
    

    Please check out this link for more options as well as a detailed explanation on speeding up gradle.

    Hope this helps!.

    0 讨论(0)
  • 2020-12-04 16:19

    Complete answer for this issue is as below:

    • Upgrade android studio to version 1.3(stable) or above 1.4(beta at the time of writing this).
    • Upgrade gradle to 1.3.+(+ can be replaced with some positive number) change it in your build.gradle file.
    • change your gradle-wrapper.properties files and add distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip in last(you can remove any old entry).
    • Go to Preference -> Gradle and set it to work offline.

    woila!!! I am able to compile and run the code in less then ~5 sec (I really mean it)

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