Android提高gradle编译速度

分配更大的存储空间提高速度

1.配置全局的gradle的

2.查找gradle.properties文件路径

我的是mac环境在home目录下的.gradle文件夹下,如果没有新建gradle.properties

3.设置内容

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# 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:decoupled_projects
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx4096m
org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

4.注意事项

具体的项目下面的buuld.gradle文件配置,里面的javaMaxHeapSize要比上面的org.gradle.jvmargs=-Xmx4096m小

dexOptions {
    dexInProcess = true
    javaMaxHeapSize “3g"
    preDexLibraries = false
    incremental true
  }

你可能感兴趣的:(Android提高gradle编译速度)