Build bigger, better: Gradle for large projects (Google I/O'19)

Android Developers · 17K views · 2019 · 37:25

Open on YouTube

Testing, debugging & developer toolsSoftware performance & optimizationSoftware architecture & designtalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when asking or answering how to speed up Gradle configuration in large multi-module Android projects and how AndroidX organizes its build.

Recommended by 1 people across 1 different months, 2019 to 2019.

What it is

A Google I/O 2019 session by Aurimas Liutikas and Xavier Ducrohet of the Android team on structuring Gradle builds for large codebases. It covers how AndroidX uses Android Studio and the Android Gradle Plugin, what worked, what to avoid, and new plugin features for faster, more maintainable builds.

What people said

Recommends Maksim Turaev · 2019-12 · Stack Overflow · on “Gradle Profile Slow Configuration”

Try to use gradle-profiler [LINK] with Chrome Trace option on ./gradlew help task. This will generate in depth detailed graphical report of configuration process. You will probably see what your build is busy doing. see also: [LINK] and: [this video]

Cites Majkeee · 2019-06 · Stack Overflow · on “Gradle configuration takes more than few seconds”

I am trying to optimize build process of Android application. It is a multimodule project (63 modules) and pretty much all of them are android-library. I have tried to comment out everything possible, yet my configuration is stuck at 25 seconds. All internet resources say it should be around 1-2 seconds. ( [this video] ) Everything takes 0.001s or a little bit more and then callback which take 0.8 seconds (which is still okay), but what is "script application"? [LINK] ./gradlew temp:assembleDebug --scan --no-build-cache --refresh-dependencies --configure-on-demand --daemon I have also played with different memory variables in my gradle.properties but this number does not get reduced.

Cites Majkeee · 2019-06 · Stack Overflow · on “Gradle configuration takes more than few seconds”

yeah, that's the question. I might not understand it correctly. [this video] They have 100 modules. All of them could be pure java/kotlin modules, but then the number of tasks is too high.

Cites tir38 · 2019-07 · Stack Overflow · on “How to configure every Kotlin project in Gradle multi-project build?”

One solution is to start to use a custom plugin for your project. This is exactly what the AndroidX team did import org.gradle.api.Plugin import org.gradle.api.Project import org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper import org.jetbrains.kotlin.gradle.tasks.KotlinCompile class MyPlugin : Plugin<Project> { override fun apply(project: Project) { project.plugins.all { when (it) { ... is KotlinBasePluginWrapper -> { project.tasks.withType(KotlinCompile::class.java).configureEach { compile -> compile.kotlinOptions.allWarningsAsErrors = true compile.kotlinOptions.jvmTarget = "1.8" } } } } } You'll need to setup all the boiler plate to get this setup, but the long term payoff is hi