Recently, I was trying to create a Java/Kotlin module for my Android application.
When I was creating Retrofit Interceptor
, there was an error saying:
Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option.
Here is the screen shot of the exact error:
I know how to set -jvm-target
for my Android module. But I am not able to find an answer for how to set it in Java/Kotlin module.
Here is what I have already tried:
[Solution 1 (Not Working)]
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
compileKotlin {
targetCompatibility(JavaVersion.VERSION_1_8)
}
[Solution 2 (Not Working)]
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
Above code gave me following error:
Could not find method kotlinOptions() for arguments