Hej! Im working with the Android side of a multipl...
# multiplatform
z
Hej! Im working with the Android side of a multiplatform project, and Ive been completely pwned by the build times. To the point that Im fairly certain that something is terribly wrong. • Compiling and running the desktop variant takes roughly 2 seconds on average. I dont have any data for this specifically, but its very quick. • When it comes to Android, Im seeing average build times of around 5 minutes and looking at a build scan I can see that some very small modules take a few minutes to compile. This tells me that something is at odds, but I dont really understand what that might be? More details in 🧵
For example, in the timeline view of a build scan I can see that: :navigator 3m 38.866s That module is just a shared module between many other modules. It has one object, a sealed interface with ~50 classes and a dependency on coroutines + a very tiny in house library (which also just depends on coroutines). This is the involved
build.gradle.kts
file:
Copy code
plugins {
    alias(config.plugins.multiplatform.android)
    alias(config.plugins.multiplatform.jvm)
}

kotlin {
    sourceSets.commonMain.dependencies {
        api(config.aggregate.core)

        implementation(libs.coroutines)
    }
}
config.plugins.multiplatform.x
are convention plugins that I share between my projects, containing stuff like:
Copy code
configure<KotlinMultiplatformExtension> {
    applyDefaultHierarchyTemplate()

    compilerOptions {
        freeCompilerArgs.addAll(CompilerArgs)
    }
}
Copy code
val CompilerArgs =
    listOf(
        "-Xskip-prerelease-check",
        "-Xexpect-actual-classes",
        "-Xcontext-receivers",
        "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
    )
And
jvm() android()
etc. Im really clueless unfortunately, this project is even just a subset of the whole project - ironically to speed up build times when developing a subset of its features.
a
Hi. How do you build Android? Maybe you use too wide gradle task for that (e.g. assembleRelease, which may include minification,, obfuscation, signing, etc.)
z
Hey Andrei! I'm using the default that you get when you add an Android run configuration. The slow task is compileDebugKotlinAndroid.
e
does https://blog.jetbrains.com/kotlin/2022/06/introducing-kotlin-build-reports/ help narrow down what is slow within the kotlin compile?
z
Awesome, that helps a lot: No incremental compilation due to
kotlin.compiler.execution.strategy=in-process
(I added this yesterday after asking AI about the issues). One of my convention plugins for multiplatform adds (by mistake) android-library to every module its applied to. Ive been using this for a lot of projects, I think the extra time just grows exponentially due to this project being ridiculous in size. These two tweaks brought the build time down from 5 minutes to 5 seconds. thank you color
🤯 1
😬 1