https://kotlinlang.org logo
Title
c

Colton Idle

10/29/2021, 4:39 AM
I'm going back into my old projects and trying to add @Preview since I was able to get it to work now in plain old Android Compose projects. But now I have a jetbrains compose project, and I have an
androidMain
folder that I'd like to be able to use @Preview. Then in my commoncomposables module build.gradle.kts I have
named("androidMain") {
  dependencies {
    implementation("androidx.compose.ui:ui-tooling-preview:1.1.0-beta01")
    implementation("androidx.compose.ui:ui-tooling:1.1.0-beta01")
But as you can see, the IDE doesn't give me the code/design/split pane. Does anyone know if I should be able to see that pane so I can have previews without deploying to device? Note: I don't care about previewing my desktop composables or anything, I just want my androidMain folder to be able to preview as you would in a normal android compose app.
What I'm looking for is being able to see this in AS, but I don't
j

Javier

10/29/2021, 9:20 AM
preview only works in jvmMain and/or androidMain
there is a open issue about this one in compose-jb
in other words, you have to set the function which has the @Preview inside jvmMain and/or androidMain
c

Colton Idle

10/29/2021, 2:08 PM
Yeah. I'm in androidMain, but that's not working.
Repro'd it not working in the jb compose template https://github.com/JetBrains/compose-jb/issues/1327
c

Chris Sinco [G]

11/03/2021, 2:15 AM
If you are using IntelliJ, I’m not sure the same split view is available since that is specifically implemented that way for design tools in Android Studio
If you are using AS, I don’t know if the project structure is supported which maybe is why it’s not showing up. If you have a link to an example project, we can take a look on the Studio side
@nosuid might have more insight
c

Colton Idle

11/03/2021, 2:37 AM
Yeah, I have a sample (which just so happens to be the multiplatform-template in the jb compose repo. Created an issue here: https://issuetracker.google.com/issues/204791546