Skip to content

IMPORTANT: Fix project breaking changes after the Gradle AGP Kotlin toolchain upgrade

Elissa-AppDevforAll edited this page Aug 24, 2026 · 2 revisions

Updating CoGo Projects: Gradle 9.6.1, AGP 9.3.1, Kotlin 2.3.21

This information applies to the release that moves Code on the Go (CoGo™) to Gradle 9.6.1, AGP 9.3.1, and Kotlin 2.3.21.

New projects created after the update will work correctly with no action from you. Projects you made with an older CoGo version will not build until you change a few lines in them. This page shows exactly what to change.

Your projects are safe. They are stored outside the app and are not deleted by installing or uninstalling CoGo.

How to update a project created before the upgrade

Open the project and try to build. If it builds, you are done. If it fails, make the changes below.

First, check which kind of project you have. Look for a file called gradle/libs.versions.toml.

  • No such file (most projects): follow Case A.
  • The file exists (Compose projects, or projects you already updated): follow Case B.

Case A: no libs.versions.toml

1. In the build.gradle.kts in your project's top level (not the one inside app)

Find the text below (your project might use different numbers than 8.11.0):

plugins {
    id("com.android.application") apply false version "8.11.0"
    id("com.android.library") apply false version "8.11.0"
}

Replace it with the code below. Because the version changes and the whole buildscript block is new, paste it above plugins:

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.21")
    }
}

plugins {
    id("com.android.application") apply false version "9.3.1"
    id("com.android.library") apply false version "9.3.1"
}

2. In app/build.gradle.kts, the plugins block

Find this:

plugins {
    id("com.android.application") version "8.11.0"
    kotlin("android") version "1.9.22"
}

Important: The Kotlin line must be entirely removed. The new build tools compile Kotlin themselves and will refuse to run if the Kotlin line is still there.

Replace it with the code below:

plugins {
    id("com.android.application") version "9.3.1"
}

3. In app/build.gradle.kts, the Java target block

If your project is Java only, you will not have this block. Skip this step.

Find this:

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
    kotlinOptions.jvmTarget = "17"
}

Replace it with this:

kotlin {
    compilerOptions {
        jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
    }
}

4. In app/build.gradle.kts, remove any forced Kotlin versions

Delete these lines if they are present:

force("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.22")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.22")

5. Save, sync, and build the project

Shortcut: When you tap Save, a dialog box will ask if you also want to sync.

Case B: libs.versions.toml exists

1. In gradle/libs.versions.toml, update version info

Replace the existing [versions] section with the code below.

Note: If you don't want to make this change, disable the --offline flag (in Preferences → Build & Run → Additional Gradle flags) so that CoGo will download the versions you want to use.

[versions]
agp = "9.3.1"
kotlin = "2.3.21"

2. In app/build.gradle.kts, delete the Kotlin plugin line

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.jetbrains.kotlin.android)   // <-- delete this line
}

3. In the top-level build.gradle.kts, add a buildscript block

The existing file does not have a buildscript block. Paste this in above plugins:

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.21")
    }
}

4. In app/build.gradle.kts, the Java target block

If your project is Java only, you will not have this block. Skip this step. Otherwise, find this:

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
    kotlinOptions.jvmTarget = "17"
}

Replace it with this:

kotlin {
    compilerOptions {
        jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
    }
}

5. In app/build.gradle.kts, remove any forced Kotlin versions

Delete these lines if present:

force("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.22")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.22")

6. Save, sync, and build.

If something goes wrong

If you see this What to do
A long error mentioning InternalProblems Your AGP version is still old. Set it to 9.3.1.
The error The org.jetbrains.kotlin.android plugin is no longer required Delete the Kotlin plugin line.
The error Using kotlinOptions is an error Replace the kotlinOptions block.
NoClassDefFoundError: ... SpillingKt Delete the lines forcing an old Kotlin version.

Clone this wiki locally