Skip to content

Update Kotlin version #6551

@nicolas-raoul

Description

@nicolas-raoul

In gradle/libs.versions.toml change:

kotlin = "1.9.22"

to

kotlin = "2.1.0"

... then fix any build error.


Gemini also says to do the following, I am not sure how important it is:

  1. While you're in the [versions] section, you must also update your Compose BOM (Bill of Materials) to a version that's compatible with the new compiler.

    [versions]
    kotlin = "2.1.0"
    
    # Find your composeBom version and update it.
    # A version like 2024.05.00 or newer is needed.
    # Let's try a recent stable one (e.g., from January 2025):
    androidxComposeBom = "2025.01.00" 
  2. In the [plugins] section, you must add the new Compose Compiler plugin, which is now tied to the Kotlin version:

    [plugins]
    # You will see your existing plugins here
    jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
    kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
    # ...
    
    # Add this line:
    compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }

In build.gradle.kts:

  1. DELETE the old composeOptions block. For Kotlin 2.0 and newer, this is no longer used.

    // DELETE THIS ENTIRE BLOCK:
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.8"
    }
  2. ADD the new plugin to your plugins block at the very top of the file:

    plugins {
        alias(libs.plugins.android.application)
        alias(libs.plugins.jetbrains.kotlin.android)
        alias(libs.plugins.kotlin.kapt)
        alias(libs.plugins.kotlin.parcelize)
        alias(libs.plugins.compose.compiler) // <-- ADD THIS LINE
    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions