https://kotlinlang.org logo
#compose
Title
# compose
s

Shubham Singh

12/05/2023, 11:26 AM
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

Pablichjenkov

12/05/2023, 12:12 PM
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

Shubham Singh

12/05/2023, 12:27 PM
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

Pablichjenkov

12/05/2023, 12:34 PM
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

Shubham Singh

12/05/2023, 12:36 PM
Understood, many thanks!
m

Michael Paus

12/05/2023, 12:57 PM
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

Shubham Singh

12/05/2023, 1:24 PM
This works well Thank you Michael Btw, is there a way to use this globally for the whole project?
m

Michael Paus

12/05/2023, 1:41 PM
Not that I know of.
🆗 1
v

Vishnu Shrikar

12/07/2023, 8:40 AM
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

Shubham Singh

12/07/2023, 8:44 AM
@Vishnu Shrikar Put it on the top of your file Before the package and imports declaration
v

Vishnu Shrikar

12/07/2023, 8:46 AM
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