I am changing the targetSdkVersion
and compileSdkVersion
from 33 to 34.
For that I changed this:
ddistributionUrl=https://services.gradle.org/distributions/gradle-8.2-all.zip.
The project got synced successfully but when I am trying to build it it is giving me error : Inconsistent JVM-target compatibility detected for tasks compileDebugJavaWithJavac
(11) and compileDebugKotlin
(17)
I looked for various solutions where I should do:
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
but in my build.gradle
, I don’t have compileOptions
and kotlinOptions
.
Just add compileOptions
and kotlinOptions
to your android scope:
android {
compileSdk 34
defaultConfig {
minSdk 23
targetSdk 34
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
}
And don’t forget to set JRE to 17 via Android Studio:
Settings > Build,Excution,Deployment > Build Tools > Gradle -> Gradle JDK