Hello, is there any way to have a preview for `@Co...
# compose
n
Hello, is there any way to have a preview for `@Composable`s outside of the Android target? I've tried to read this mess of documentation on the topic but all that seems clear to me is
To enable Compose previews in common code of your Kotlin Multiplatform project, you need an Android target, since previews rely on Android libraries.
. So, it's not possible to preview any
@Composable
in
commonMain
target ?
a
It is as long as you have an Android target
n
Ok I understood why the preview didn't work. The commonMain preview works when using Gradle 8.x, but obviously it's no longer working when using 9.x. Another thing to add to the list of why we shouldn't migrate to Gradle 9 yet... -_- Nonetheless it feels weird to have an "empty"
androidMain
target in a pure web Compose project, but at least we can have @Previews, us non-Android Compose peasants 🤷
c
I use it with AGP 9.1.0 and Gradle 9.3.1 🤷🏻
and you don’t need the folder, the target in the
build.gradle
is enough
n
Interesting, are you using the
com.android.kotlin.multiplatform.library
plugin ?
c
yes
n
For me it didn't work the moment I switched to AGP 9.1, Gradle 9.4,
debugImplementation("org.jetbrains.compose.ui:ui-tooling:1.10.3")
->
androidRuntimeClasspath("org.jetbrains.compose.ui:ui-tooling:1.10.3")
, and
androidTarget
->
android
I followed this guide https://kotlinlang.org/docs/multiplatform/multiplatform-project-agp-9-migration.html Here's the patch for the changes I do. Doesn't work. I'm on
IntelliJ IDEA 2026.1 Build #IU-261.22158.277, built on March 25, 2026
c
Previews for me only ever worked in Android Studio. Maybe that's the difference.
Intellij so far does not support AGP 9.
a
2026.1 supports agp 9 no?
n
Yes I build just fine my webMain target like before, but no previews
a
what does it look like screenshot pls
I wasnt aware of this
But for me in one projet with compose 1.9.2 previews do not work in intellij otherwise in later versions they do