Reputation: 143
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
'compileDebugJavaWithJavac' task (current target is 1.8) and 'kaptGenerateStubsDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
And here is my app gradle file
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
}
android {
namespace 'com.waltonbd.daggerwithcheezy'
compileSdk 32
defaultConfig {
applicationId "com.waltonbd.daggerwithcheezy"
minSdk 24
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
def dagger_version = "2.40.5"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Upvotes: 0
Views: 3390
Reputation: 504
The error means there is a mismatch in the Java version being used for compilation between the compileDebugJavaWithJava
task and the kaptGenerateStubsDebugKotlin
task.
Make sure both tasks are using the same Java version. Update your Kotlin options
to use a higher version of the JVM that supports Java 17.
e.g.
...
kotlinOptions {
jvmTarget = '17'
}
Upvotes: 1