Yakubu
Yakubu

Reputation: 1109

Caused by: org.gradle.api.InvalidUserCodeException: Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac'

I am stuck with this error

Caused by: org.gradle.api.InvalidUserCodeException: Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'kaptGenerateStubsDebugKotlin' (17). enter image description here

I have tried several approach from here and here like updating my build gradle here to VERSION_17 and VERSION_21 but the error still persist

compileOptions {
    // I have tried VERSION_17 and VERSION_21
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
    jvmTarget = '17'
}

Anyone got a clue how to solve this, app/build.gradle

enter image description here

build.gradle

plugins {
    id("com.android.application") version "8.2.1" apply false
    id("com.google.devtools.ksp") version "1.9.21-1.0.15" apply false
    id("org.jetbrains.kotlin.android") version "1.9.21" apply false
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

gradle.wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Upvotes: 2

Views: 522

Answers (2)

Emre Tekin
Emre Tekin

Reputation: 472

You should set your project JDK version as 17.

You can find the settings inside And. Studio Settings under Build,Execution,Deployment / Gradle / Gradle Projects

enter image description here

Upvotes: 0

Yakubu
Yakubu

Reputation: 1109

I fixed this with this steps

  • Check for update here

enter image description here

  • Android studio navigated to install new android studio here
  • After installing new android studio, replace old android studio with new one
  • Open your project and all dependency will be install. if they are not install, invalidate your cache here and keep your finger crossed enter image description here

Upvotes: 0

Related Questions