20
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Android】DroidConSF 2017のMake Your Build Great Againで発表されたビルド高速化Tips

Last updated at Posted at 2017-11-26

DroidConSF 2017 (.droidconSF) の「Make Your Build Great Again」で発表されたビルド高速化Tipsの紹介になります。

はじめに

Tips

gradle.properties最適化

Gradle specific

gradle.properties
# Gradle daemon有効化
org.gradle.daemon=true

# daemonのヒープサイズを増やす
org.gradle.jvmargs=-Xmx2048m

# 並列ビルド有効化
org.gradle.parallel=true

# Configure on Demand有効化
org.gradle.configureondemand=true

# キャッシュ有効化
org.gradle.caching=true

Android specific

gradle.properties
# ビルドキャッシュ有効化
android.enableBuildCache=true

# 新しいDexコンパイラ有効化
android.enableD8=true

テスト分割実行

tasks.withType(Test) {
    def maxCount = gradle.startParameter.maxWorkerCount
    maxParallelForks = (maxCount < 2) ? 1 : maxCount / 2
    forEvery = 100
}

参照するリポジトリを減らす

repositories {
    jcenter()
    mavenCentral()
    maven{url "https://plugins.gradle.org/m2/"}
    google()
    maven{url "https://jitpack.io"}
}

repositories {
    maven{url "https://plugins.gradle.org/m2/"}    
    google()
}

インクリメンタルビルドを有効化する

tasks.withType(JavaCompile) {
    options.incremental=true
    options.fork=true
}

レガシーなMultiDexは避ける

minSdkVersion 19

minSdkVersion rootProject.hasProperty("lollipop") ? 21 : 19

CIでpre-dexライブラリを無効化する

android {
    dexOptions {
        preDexLibraries = !project.hasProperty("ci")
    }
}

補足

間違ってる点あればご指摘ください。

参考

Make Your Build Great Again (DroidConSF 2017) // Speaker Deck
https://speakerdeck.com/jaredsburrows/make-your-build-great-again-droidconsf-2017

Build高速化の話 // Speaker Deck
https://speakerdeck.com/kobitokaba/buildgao-su-hua-falsehua

【Android】Google I/O 2017のSpeeding up your Android Gradle buildsで発表された10のTips - Qiita
https://qiita.com/rkowase/items/808064f16272e131be63

.droidconSF 2017報告会 @ミクシィ - connpass
https://mixi.connpass.com/event/70645/

20
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?