With Gradle 8 and Kotlin 1.8 I got an error when compiling
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.
This is a multi module project, and the problem only occur to this module. But, this module also using same JVM target and compatibility target. But how does this happened?
Here is my Gradle for this module:
plugins {
id 'com.android.library'
alias libs.plugins.kotlin.android.plugin
alias libs.plugins.kotlin.kapt.plugin
alias libs.plugins.dagger.hilt.module.plugin
}
android {
namespace 'com.lelestacia.network'
compileSdk 33
defaultConfig {
minSdk 24
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
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'
}
}
I'm getting similar error. These processes worked for me.
build.gradle(:project)
plugins {
id 'com.android.application' version '8.0.0' apply false
id 'com.android.library' version '8.0.0' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
}
build.gradle(:app)
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
...
Android Studio - Gradle Projects