Android build failed for kotlin with ksp


Unable to load class 'com.google.devtools.ksp.impl.KotlinSymbolProcessing$ExitCode'
com.google.devtools.ksp.impl.KotlinSymbolProcessing$ExitCode
Dependencies
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.10'

plugins
id 'org.jetbrains.kotlin.android' version '2.3.10' apply false
id 'com.google.devtools.ksp' version '2.3.10' apply false

More error log

class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension (com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated and com.android.build.gradle.BaseExtension are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @4584c85a)
class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension (com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated and com.android.build.gradle.BaseExtension are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @4584c85a)
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Tried different version of combination for kotlin-android and ksp all of them are failed, even tried with below code but facing same error

plugins
id 'org.jetbrains.kotlin.android' version '2.4.10' apply false
id 'com.google.devtools.ksp' version '2.3.11' apply false

Already tried invalidate cache and restart IDE.

Gradle version 9.7.0 
AGP vervsion 9.3.1 
Android studio Quail 3, 2026.1.3 Patch 1
0
Aug 12 at 8:10 AM
User AvatarPratik
#android#kotlin#build#ksp

Accepted Answer

This is a known compatibility issue between KSP and the Kotlin Gradle plugin versions. They must match exactly.

With Kotlin 2.3.10 you need KSP 2.3.10-1.0.x — the first part of the KSP version must match your Kotlin version exactly.

Fix your plugins block like this:

kotlin

plugins {
    id 'org.jetbrains.kotlin.android' version '2.3.10' apply false
    id 'com.google.devtools.ksp' version '2.3.10-1.0.25' apply false
}

The KSP version format is always <kotlin-version>-<ksp-version>. You cannot mix 2.3.10 Kotlin with 2.3.11 KSP — they must start with the same Kotlin version number.

Also try these steps in order:

  1. Update your build.gradle with the matching versions above

  2. Delete .gradle folder in your project root

  3. Run ./gradlew clean in terminal

  4. Sync project again

You can always check the correct matching version at: github.com/google/ksp/releases

User AvatarRamzan
Aug 12 at 11:44 AM
0