Is OkHttp 4.0.0 intentionally incompatible with jvm target 1.6? Upgrading from OkHttp 3.12.0 to 4.0.0 I run into the following build failure.
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
On further inspection I found the root cause to be the Interceptor
interface having a static method (function inside companion object). The upgrade guide does not mention this backward incompatibility leading me to believe it's unintentional.
Found a blog post with some explanations. Since OkHttp 3.13.1 JVM target 1.8 is required. The suggested change is:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
}
I found that it still fails. Adding one more instruction finally fixes the build.
kotlinOptions {
jvmTarget = '1.8'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With