-
-
Notifications
You must be signed in to change notification settings - Fork 55
IMPORTANT: Fix project breaking changes after the Gradle AGP Kotlin toolchain upgrade
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.
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.
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"
}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"
}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)
}
}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")Shortcut: When you tap Save, a dialog box will ask if you also want to sync.
Replace the existing [versions] section with the code below.
Note: If you don't want to make this change, disable the
--offlineflag (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"plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android) // <-- delete this line
}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")
}
}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)
}
}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")| 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. |