has been developed using Android studio for more than a year, as the project grows, relying on the increase of the library, the construction speed is more and more slow, now the slowest 6 minutes to build a release of the installation package, find information on the Internet, found that can be configured to speed up the pace, Here to share with you.
Turn on gradle separate daemon
Create the Gradle.properties file under the following directory:
/home/<username>/.gradle/ (Linux)
/users/<username>/.gradle/ (MAC)
C:\users\<username>\.gradle (Windows)
and add in the file:
Modifying the Gradle.properties file under the project can also be optimized:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# project-wide gradle settings. # ide (E.g. android studio) users: # settings specified in this file will override any gradle settings # configured through the ide. # for more details on how to configure your build Environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # the Gradle daemon aims to improve the startup and execution Time of gradle. # when set to true the gradle daemon is to run the build. # todo: disable daemon on ci, since builds should be clean and reliable on servers org.gradle.daemon=true # specifies the jvm Arguments used for the daemoN process. # the setting is particularly useful for tweaking memory settings . # default value: -xmx10248m -xx:maxpermsize=256m org.gradle.jvmargs=-xmx2048m -xx: Maxpermsize=512m -xx:+heapdumponoutofmemoryerror -dfile.encoding=utf-8 # When configured, gradle will run in incubating parallel mode. # this option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec :d ecoupled_projects org.gradle.parallel=true # enables new incubating mode that Makes gradle selective when configuring projects. # only relevant projects are configured which results in faster builds for large multi-projects. # Http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand Org.gradle.configureondemand=true |
At the same time, these parameters can also be configured in the previous user directory in the gradle.properties file, so it is not for a project to take effect, but for all projects to take effect.
The above configuration file is mainly to do, increase the size of Gradle running Java Virtual machine, let gradle at compile time use independent process, let Gradle can run parallel.
Modify the Android Studio configuration
In the configuration of Android Studio, turn on offline mode and modify the configuration. The actual configuration is the same as in the above section, where the configuration is only effective when the IDE is built and the command-line build does not take effect.
Accelerate Android Studio/gradle Build