How do I troubleshoot why Preview annotation isn't...
# compose
How do I troubleshoot why Preview annotation isn't working in my project? It does work on very simple UIs, where I show a text box, for example, that is hard-coded. I am using Kotlin 1.6.10 on compose 1.2.0-alpha07
If you click that blue Info icon in the top right of the Preview window that opens a panel where the error message shows up.
What version of Android Studio are you using?
Bumblebee is the version. java.lang.IllegalStateException: KoinApplication has not been started at org.koin.core.context.GlobalContext.get(GlobalContext.kt:36) at at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
it’s because you’re attempting to use your DI injector on the preview instead of having
val viewModel: MyOutfitPickerViewModel by inject()
inside the composable function body, I would provide it as a parameter, and then you can use a
to pass in a mock/fake viewModel
👍 1
Ah yes. Preview doesn't support DI yet. Though I think we should make that clearer with error messaging