Speed Up Gradle Build

First of all, upgrade your Android Studio to 2.1.0 and use android gradle plugin version to 2.1.0. It will help you open following features as default. You can see more information in here.

  • New features in 2.1.0
    • incremental Java compilation
    • dexing-in-process
  • New features in 2.0.0
    • incremental builds

Then we can start:
1.Enable offline mode in your Android Studio.

Highlight with shit color...

2.Configure your gradle.properties file, normally I will put it under project root folder. (I don't have one, how to create it?)
Add following statements in your gradle.properties

# 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=-Xms512m -Xmx1024m -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

# 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

org.gradle.workers.max=4
  • Parallel mode would't help you too much, because most projects only contain dependency module.
  • You will ask where's the daemon mode statement? People on the internet told you should use gradle daemon. I agree with them, but:
    • Gradle team suggest not use gradle daemon in CI job, so I didn't put it in gradle.properties file, because gradle.properties will also impact your CI job as default. You can see more information in here.

    • Gradle daemon will enable when build in Android Studio.

    • If you need to build project in command line of your local machine, please enable it manually by adding "--daemon" at the end of your gradle command, like following command.

      gradle assembleDebug --daemon
      # when you want to stop it, use "gradle --stop"
      

That's all. Thanks for reading!
My personal project commit for this

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市芥牌,隨后出現(xiàn)的幾起案子许布,更是在濱河造成了極大的恐慌衩辟,老刑警劉巖盐欺,帶你破解...
    沈念sama閱讀 218,755評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件赁豆,死亡現(xiàn)場離奇詭異,居然都是意外死亡冗美,警方通過查閱死者的電腦和手機(jī)魔种,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,305評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來粉洼,“玉大人节预,你說我怎么就攤上這事∈羧停” “怎么了安拟?”我有些...
    開封第一講書人閱讀 165,138評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長宵喂。 經(jīng)常有香客問我糠赦,道長,這世上最難降的妖魔是什么锅棕? 我笑而不...
    開封第一講書人閱讀 58,791評論 1 295
  • 正文 為了忘掉前任拙泽,我火速辦了婚禮,結(jié)果婚禮上哲戚,老公的妹妹穿的比我還像新娘奔滑。我一直安慰自己,他們只是感情好顺少,可當(dāng)我...
    茶點故事閱讀 67,794評論 6 392
  • 文/花漫 我一把揭開白布朋其。 她就那樣靜靜地躺著,像睡著了一般脆炎。 火紅的嫁衣襯著肌膚如雪梅猿。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,631評論 1 305
  • 那天秒裕,我揣著相機(jī)與錄音袱蚓,去河邊找鬼。 笑死几蜻,一個胖子當(dāng)著我的面吹牛喇潘,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播梭稚,決...
    沈念sama閱讀 40,362評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼颖低,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了弧烤?” 一聲冷哼從身側(cè)響起忱屑,我...
    開封第一講書人閱讀 39,264評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后莺戒,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體伴嗡,經(jīng)...
    沈念sama閱讀 45,724評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年从铲,在試婚紗的時候發(fā)現(xiàn)自己被綠了瘪校。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,040評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡食店,死狀恐怖渣淤,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情吉嫩,我是刑警寧澤,帶...
    沈念sama閱讀 35,742評論 5 346
  • 正文 年R本政府宣布嗅定,位于F島的核電站自娩,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏渠退。R本人自食惡果不足惜忙迁,卻給世界環(huán)境...
    茶點故事閱讀 41,364評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望碎乃。 院中可真熱鬧姊扔,春花似錦、人聲如沸梅誓。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,944評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽梗掰。三九已至嵌言,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間及穗,已是汗流浹背摧茴。 一陣腳步聲響...
    開封第一講書人閱讀 33,060評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留埂陆,地道東北人苛白。 一個月前我還...
    沈念sama閱讀 48,247評論 3 371
  • 正文 我出身青樓,卻偏偏與公主長得像焚虱,于是被迫代替她去往敵國和親购裙。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,979評論 2 355

推薦閱讀更多精彩內(nèi)容