Issue
I downloaded the demo project to study kotlin compose.
I try to add @Preview on a @Composable fun, but get warn that: Unresolved reference: Preview
I add implementation("androidx.compose.ui:ui-tooling-preview:1.1.1")
in kotlin.sourceSets.named("CommonMain").dependencies
in build.gradlw.kts:
named("commonMain") {
dependencies {
api(compose.runtime)
api(compose.foundation)
api(compose.material)
api(compose.materialIconsExtended)
implementation("androidx.compose.ui:ui-tooling-preview:1.1.1")
}
}
But still get Unresolved reference: Preview error.
I use IDEA 2021.3.3, Build #IU-213.7172.25, built on March 16, 2022.
Solution
You need to import androidx.compose.desktop.ui.tooling.preview.Preview
to preview in desktop.
Go to Settings > Plugins > search in the marketplace for Compose Multiplatform IDE Support and Install this plugin.
After that, you can use Preview annotation and it will import the correct lib.
Answered By - Roman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.