It is a known bug: https://issuetracker.google.com/issues/227767363
Google is currently working on a fix but there is already a workaround: add these dependencies to every module where you use the Compose preview:
debugImplementation "androidx.customview:customview:1.2.0-alpha01"
debugImplementation "androidx.customview:customview-poolingcontainer:1.0.0-alpha01"
If you have a common core/base/ui module, you can add it there and use Api
instead of Implementation
to avoid adding it to every module:
debugApi "androidx.customview:customview:1.2.0-alpha01"
debugApi "androidx.customview:customview-poolingcontainer:1.0.0-alpha01"
Artifacts release reference