Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Follow publication

Jetpack Compose: @PreviewParameter causes Preview to disappear!

Jermaine Dilao
Geek Culture
Published in
2 min readAug 31, 2021

--

Not even a single error was shown

Photo by Jason Strull on Unsplash

I’ve been exploring Kotlin Multiplatform Mobile lately and using Jetpack Compose on my Android app.

I encountered a very weird scenario where my Preview is not showing! Not even a single error was shown in Android Studio. 🤨

Composable function

Above is my composable function that I want to preview, but Android Studio is literally showing nothing. Blank. Empty. I’ve been going back and forth to try to discover what’s causing this issue (even googling did not help).

The solution 🤦‍♂️ was…

It turns out that I had my PreviewParameterProvider declared in private and turning it to public or simply removing the visibility modifier fixed it.

private PreviewParameterProvider

This wasn’t even documented!

I hope Google will make it clear in the documentation or at least give an error in Android Studio so developers won’t encounter this frustrating and time-wasting scenario.

I’m writing this in the hope to help someone out there.

That’s it for this short article. Happy coding!

--

--

Jermaine Dilao
Jermaine Dilao

Written by Jermaine Dilao

A Work in Progress Android Developer. You can check me @ https://jermainedilao.framer.website. | đź’» Senior Android Engineer @ Speakap

Responses (2)

Write a response