Building and running app via Gradle and Android Studio is slower than via Eclipse

前端 未结 28 1942
太阳男子
太阳男子 2020-11-22 08:21

I have a multi-project (~10 modules) of which building takes about 20-30 seconds each time. When I press Run in Android Studio, I have to wait every time to rebuild the app,

28条回答
  •  旧时难觅i
    2020-11-22 09:00

    Update After Android Studio 2.3

    All answers are great, and I encourage to use those methods with this one to improve build speed.

    After release of android 2.2 on September 2016, Android released experimental build cache feature to speed up gradle build performance, which is now official from Android Studio 2.3 Canary. (Official Release note)

    It introduces a new build cache feature, which is enable by default, can speed up build times (including full builds, incremental builds, and instant run) by storing and reusing files/directories that were created in previous builds of the same or different Android project.

    How to use:

    Add following line in your gradle.properties file

    android.enableBuildCache = true
    # Set to true or false to enable or disable the build cache. If this parameter is not set, the build cache is enable by default.
    

    Clean the cache:

    • There is a new Gradle task called cleanBuildCache for you to more easily clean the build cache. You can use it by typing the following in your terminal:

      ./gradlew cleanBuildCache

    • OR You can clean the cache for Android studio 2.2 by deleting all the files store at location

      C:\Users\\.android\build-cache

提交回复
热议问题