compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

IDEA preview plugin doesn't work for compose multiplatform application

Open iptton opened this issue 4 years ago • 7 comments

when run task: desktop:configureDesktopPreviewJvm or common:configureDesktopPreviewDesktop, error occurs

Some problems were found with the configuration of task ':desktop:configureDesktopPreviewJvm' (type 'AbstractConfigureDesktopPreviewTask').

  • In plugin 'org.jetbrains.compose.ComposeCompilerKotlinSupportPlugin' type 'org.jetbrains.compose.desktop.preview.tasks.AbstractConfigureDesktopPreviewTask' property 'idePort$compose' doesn't have a configured value.

iptton avatar Dec 01 '21 06:12 iptton

Hello! Which IDEA and which plugin version do you use?

akurasov avatar Dec 01 '21 10:12 akurasov

Hello! Which IDEA and which plugin version do you use?

IDEA 2021.2.3(Ultimate Edition) Build #IU-212.5457.46 Compose Multiplatform IDEA Support : 1.0.0-rc10

It works only in "Compose Desktop" project.

iptton avatar Dec 02 '21 02:12 iptton

after update to 1.0.0 , still not work. @Preview annotation cann't be resolved

iptton avatar Dec 02 '21 02:12 iptton

Some problems were found with the configuration of task ':desktop:configureDesktopPreviewJvm' (type 'AbstractConfigureDesktopPreviewTask').

@iptton do you run the task manually? It should be run only from Intellij plugin.

@Preview annotation cann't be resolved

Do you have a dependency on compose.desktop.currentOs? Please note, that the preview annotation and functionality is not available in common code yet. Here is the example of MPP project configuration https://github.com/JetBrains/compose-jb/blob/master/idea-plugin/examples/simple-preview-example/mpp-jvm/build.gradle.kts (note that in the example the preview is available only in desktopMain source set, but unavailable in commonMain source set)

AlexeyTsvetkov avatar Dec 02 '21 06:12 AlexeyTsvetkov

@iptton do you run the task manually? It should be run only from Intellij plugin.

yes ,because i cannot see preview, i tried to run it manually

Do you have a dependency on compose.desktop.currentOs?

I am using @preview in common module androidMain/commonMain/desktopMain folders of this project: https://github.com/JetBrains/compose-jb/tree/master/examples/todoapp

seams it has configured correctly but not work.

And i saw some error in file: desktopMain/kotlin/example..../Utils.kt

Cannot access 'java.io.Serializable' which is a supertype of 'kotlin.Int'. Check your module classpath for missing or conflicting dependencies

The project's clean, not changed any thing but add code like:

@Preview
@Composable
fun Test(){

}

iptton avatar Dec 02 '21 08:12 iptton

@iptton I had a similar problem and I just found out that Preview was not working with Java 17. In order to get previews to work I set kotlinOptions.jvmTarget = "16" in my build.gradle.kts.

ryanmitchener avatar Jan 22 '22 05:01 ryanmitchener

I experience a similar issue on IDEA 2022.3.3: no preview. Turns out it's just a misleading user experience for someone used compose on Android Studio.

The preview doesn't appear automatically, I need those 2 steps to get it:

  • run the app once, this will add a small icon in front of composable functions
  • click the small preview icon of the composable I want see

mrlem avatar Apr 14 '23 22:04 mrlem

i renamed my preview functions to <>Preview() with the annotation and it worked

musokeharun avatar May 22 '23 13:05 musokeharun

saved

@iptton I had a similar problem and I just found out that Preview was not working with Java 17. In order to get previews to work I set kotlinOptions.jvmTarget = "16" in my build.gradle.kts.

saved my life. I'd never thought it'd be the sdk's problem

hereisderek avatar Jun 15 '23 23:06 hereisderek

Why is it still not fixed in 2023 with version 1.4.3?? Java 17 is so popular today :stuck_out_tongue_closed_eyes:

xinkunZ avatar Aug 11 '23 03:08 xinkunZ

Same issue with compose version 1.4.3 and Java 17 ...

gastsail avatar Aug 15 '23 17:08 gastsail

issue still here

Krobys avatar Feb 24 '24 20:02 Krobys

yeah still not working

hasanelfalakiy avatar Apr 02 '24 10:04 hasanelfalakiy

i tried with fleet IDE and it should work https://www.jetbrains.com/fleet/

ThuanPx avatar Apr 10 '24 17:04 ThuanPx

@ThuanPx No,Fleet can't preview... , Just follow guide , I can't preview any desktop preview ~ Fleet -1.35.115 image

ALuoBo avatar Jun 04 '24 11:06 ALuoBo

@ThuanPx No,Fleet can't preview... , Just follow guide , I can't preview any desktop preview ~ Fleet -1.35.115 image

are you using jdk 11 or 17?

hasanelfalakiy avatar Jun 04 '24 11:06 hasanelfalakiy

@ThuanPx No,Fleet can't preview... , Just follow guide , I can't preview any desktop preview ~ Fleet -1.35.115 image

are you using jdk 11 or 17?

I am using openjdk 17 ~

ALuoBo avatar Jun 05 '24 01:06 ALuoBo

@ThuanPx No,Fleet can't preview... , Just follow guide , I can't preview any desktop preview ~ Fleet -1.35.115 image

are you using jdk 11 or 17?

I am using openjdk 17 ~

try using jdk 11

hasanelfalakiy avatar Jun 05 '24 02:06 hasanelfalakiy