I’m trying to get `@Preview` working in a multi mo...
# compose
c
I’m trying to get
@Preview
working in a multi module project. Has anyone had trouble doing this?
I’m using compose version
1.3.0-beta02
, compiler version
1.3.1
, Kotlin version
1.7.10
.
I have a
:core
module with a few reusable `@Composable`s. My
:app
module depends on
:core
and uses these composables.
I have a “Settings” screen in
:app
which uses several composables from
:core
. The
@Preview
for this screen works well.
I want to create previews for the individual composables in
:core
. But I always get the error:
The project needs to be compiled for the preview to be displayed
If I copy-paste the exact
@Preview
function from
:core
into
:app
, the preview renders fine. I can’t figure out what the difference is between these two modules. Versions are all the same.
a
You might be missing the preview-related dependencies in your
:core
library modules? You could also look at https://github.com/android/nowinandroid as a reference for a multi-module setup. There was at least one weird preview-related dependency issue IIRC
c
Thanks for the link, I’ll take a look and report back if I figure anything out
Fwiw both modules have the same Compose deps, except
:app
also has navigation and material icons
a
Yep here were the lines I was remembering: https://github.com/android/nowinandroid/blob/9d8914693a5b066572d97cdd88e3f986bdb271d4/core/designsystem/build.gradle.kts#L45-L49
navigation
might be the culprit, if it pulls in
viewmodel
-related deps
c
ooooh thanks for the tip
Perhaps I’ll just update to Dolphin for now
Btw I updated to Dolphin and all works well now
a
Nice to hear! We should probably remove those workarounds in Now in Android