第一次从github clone下来是执行
./gradlew :android:assembleDebug --dry-run
第二
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
org.gradle.parallel=true
# When set to true the Gradle daemon is used to run the build. For local developer builds this is our favorite property.
# The developer environment is optimized for speed and feedback so we nearly always run Gradle jobs with the daemon.
org.gradle.daemon=true
第三
在所在项目的build.gradle中的android 代码块中加入如下
//开启gradle的增量编译,加快编译。
// 使用递增的dex分包
dexOptions {
incremental true
}
or
dexOptions {
incremental true
javaMaxzhongHeapSize "12g"
}
or
dexOptions {
incremental true
javaMaxHeapSize "4096M"
jumboMode true
maxProcessCount 8 //默认进程是4
preDexLibraries false
threadCount 8 //默认线程是4
}
在你的setting.file文件中你可以拍配置你的gradle参数
# 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
总结 :配置你的Gradle properties
#设置并行
org.gradle.parallel=true
#设置守护进程
org.gradle.daemon=true
#调整heap内存的大小
org.gradle.jvmargs=-Xms256m -Xmx1024m
#开启孵化模式:
org.gradle.configureondemand=true
#开启缓存:
android.enableBuildCache=true
android.useDeprecatedNdk=true
在终端输入
gradle build --daemon