Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Error: 'kspDebugKotlin' task (current target is 17)

Execution failed for task ':app:kspDebugKotlin'. Unable to build with ksp

'compileDebugJavaWithJavac' task (current target is 1.8) and 'kspDebugKotlin' task (current target is 17) JVM target compatibility should be set to the same Java version.

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
}
like image 766
Sohaib Ahmed Avatar asked Aug 30 '25 15:08

Sohaib Ahmed


2 Answers

As well as

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

Add (at the same level as android {}):

kotlin {
    jvmToolchain(8)
}
like image 172
deive Avatar answered Sep 02 '25 10:09

deive


I don't know why it causing problem, but I added this in gradle(project) and it worked.

allprojects {
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
}
like image 27
Sohaib Ahmed Avatar answered Sep 02 '25 11:09

Sohaib Ahmed