加速gradle的一些经验

第一次从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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,802评论 25 709
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,027评论 19 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,977评论 6 342
  • I have dipped the vessel of my heart into this silent hou...
    我是呜呜阅读 494评论 3 2
  • 妞妞—一个父亲的札记 读后感 一个小生命的孕育奇妙,神秘,承载着期许,希望。 一个小...
    如何是我阅读 203评论 0 1