As your project grows larger and more dependent libraries are added, the gradle will build more slowly, slowly, and with suspicion of your computer configuration,
If your English is good, then you can look at the official document of Gradle, which has the relevant introduction
Http://www.gradle.org/docs/current/userguide/build_environment.html
First, let's take a look at Gradle's introduction.
Gradle provides several options to make it easy to configure a Java process that will be used to perform the build. At the same time can be configured in your local environment through gradle_opts or java_opts, some settings such as JVM memory settings, Java, daemon on/off can be more useful if they can with VCs project version, so that the entire team can use a consistent environment. Build a consistent environment build simple to set these into gradle.properties files.
The main problem to get the project to compile faster is to configure Gradle.properties
If you do not have any previous configuration, then it will be the following interface (except for annotations)
# # Project-wide Gradle settings.## For more details about how to configure your build environment visit//If you need more information, you can refer to the official website of Gradle# http://www.gradle.org/docs/current/userguide/build_environment.html## Specifies the JVM arguments used for the daemon process.//uses the JVM for daemons (that is, auto-start, background run, amount, after I test, configureOrg.gradle.daemonwill eat part of the memory, but will make your project compile more quickly, for specific reasons later on)
# The setting is particularly useful for tweaking memory settings.//This configuration compensates for compilation of the required Ram# Default value:-xmx10248m-xx:maxpermsize=256m//defaults are ...# Org.gradle.jvmargs=-xmx2048m-xx:maxpermsize=512m-xx:+heapdumponoutofmemoryerror-dfile.encoding=utf-8 ## When configured, Gradle'll run in incubating parallel mode.# This option is should only is used with decoupled projects. More details, visit# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects# org.gradle.parallel=true#Thu Mar 08:35:57 CST
There are several methods in this configuration file
1. We can add at the end of the document
Org.gradle.daemon=true
Running on the Gradle Java Virtual Machine (JVM) and using some support libraries requires a simple initialization time. So it sometimes seems a little slow to start. The solution to this problem is the Gradle daemon: a long-lived background process executes more quickly than other situations. We do this by avoiding the expensive boot process, as well as leveraging the cache to keep your project's data in memory. Running Gradle with the daemon is no exception. Simple configuration Whether you want to use it, the others are handled transparently by Gradle.
2. Configure the memory size associated with the daemon Org.gradle.jvmargs we can add another line.
Org.gradle.jvmargs=-xmx2048m-xx:maxpermsize=512m-xx:+heapdumponoutofmemoryerror- Dfile.encoding=utf-8
Specifies that Jvmargs is used for daemons. Adjusting settings for memory settings is especially useful.
3. If you compile a third-party library, there is no compile "file" in module Gradle, then we can directly use the offline mode (when in this way, if you refer to the library is not local, it may lead to compilation failure, you need to remove Tick offline),
For Example
' io.reactivex:rxandroid:1.1.0 '
My configuration diagram
In short, this is my final configuration diagram, even if you are in the setting configuration, it will eventually be reflected in the gradle.properties, we will feel that their old computer will fly ~~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Everybody go Try It
Accelerating Android Studio/gradle Build-up