So, we updated to the latest version of the gradle plugin.
Since then my builds have become super-slow. The main culprit seems to be
compileDebugKotlin
which takes over 5 minutes as can be seen in the analyser
The weird thing is that another person is getting much better times with exactly the same setup.
gradle.properties:
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
#org.gradle.jvmargs=-Xmx1Fg536m
# Increase memory allotted to JVM
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -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
#android.enableSeparateAnnotationProcessing=true
android.useAndroidX=true
android.enableJetifier=true
android.injected.testOnly = false
org.gradle.caching=true
org.gradle.daemon=true
# Enable Configure on demand
org.gradle.configureondemand=true
gradle-wrapper.properties
#Wed Jan 12 11:49:46 MSK 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
project level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.7.0"
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
dependencies {
//classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.10'
classpath "io.realm:realm-gradle-plugin:6.0.2"
// classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' }
maven { url 'https://jitpack.io' }
maven {
url 'https://maven.wefi.com/repository/wefi-release-repo'
artifactUrls 'https://maven.wefi.com/repository/wefi-release-repo'
}
configurations.all {
resolutionStrategy {
force 'org.xerial:sqlite-jdbc:3.34.0'
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I was using Kotlin plugin 1.6.10 but downgraded to 1.6.0 to match the other guy's version. Still no improvement.
The weird thing is that if we go back to the previous gradle it all works great. Super fast builds.
Edit: I am not asking WHY it is rebuilding that module. That I know. My question is why the build is taking such a ridiculous amount of time.
compileDebugKotlin
task comes from thekotlin-gradle-plugin
, which is not part of the Android Gradle plugin. You can addkotlin.build.report.enable=true
,kotlin.build.report.verbose=true
,kotlin.build.report.metrics=true
to yourgradle.properties
file, and that should generated more information under$rootProject/build/repor
, with breakdown of how time is spent during Kotlin compilation.