Hi friends, while using certain Compose Multiplatf...
# compose
s
Hi friends, while using certain Compose Multiplatform libraries, I'm seeing this error in my IDE and I'm not sure how to fix this. Please help: Here's the error message:
Copy code
Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
Also shown in the first image below And over the internet, people have given suggestions to set
androidTarget.compilations.all.kotlinOptions.jvmTarget = "11"
and set
android.compileOptions.sourceCompatibility
and
targetCompatibility
to JavaVersion.VERSION_11 But I can see that's already done in my project (also shown in the second image below) I have also tried invalidating the cache and restarting Android Studio. Btw, I am using
Android Studio Iguana | 2023.2.1 Canary 16
, could that have anything to do with the issue? Or is there anything else I'm missing here?
p
Copy code
compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
Try like above. Could you identify the specific Library that when included triggers the issue? If so try to update that library. Oh wait, I see the first screenshot, nvm.
s
Try like above. Could you identify the specific Library that when included triggers the issue?
If so try to update that library. Oh wait, I see the first screenshot, nvm.
Glad that you saw the library. Just to be clearer, I'm seeing this with 2 libraries: 1. io.github.qdsfdhvh:image-loader 2. moe.tlaster:precompose Attaching error from 2nd library below:
p
I see in the library there are 2 functions named ImageRequest, one is an inline function and seems to be causing the problem. Can you try adapting your code to use the non inline version. Also, I would open an issue in the compose-image-loader repo. Maybe someone dealt with it before.
s
Understood, many thanks!
m
Actually this is an IDE error but it seems to be fixed in the latest IntelliJ EA release. Solution: https://youtrack.jetbrains.com/issue/KTIJ-20816/Bogus-error-Cannot-inline-bytecode-built-with-JVM-target-11-into-bytecode-that-is-being-built-with-JVM-target-1.8 add
@file:Suppress(“INLINE_FROM_HIGHER_PLATFORM”)
to every affected file, and now your IDE is usable again!
🙌 3
s
This works well Thank you Michael Btw, is there a way to use this globally for the whole project?
m
Not that I know of.
🆗 1
v
Is there a reason the default target is a dinosaur version of JVM?
also where do i put the @file thing, it just gives me a an error saying "expecting top level declaration"
s
@Vishnu Shrikar Put it on the top of your file Before the package and imports declaration
v
ok thank you that worked, turns out that Michaels slack message had the good looking but bad quotes on it 😛 I should have looked closer, for anyone who needs it.
Copy code
@file:Suppress("INLINE_FROM_HIGHER_PLATFORM")
and thanks michael and shubham for the help
👏 1