diff --git a/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt b/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt index 9e785976..b96cf469 100644 --- a/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt +++ b/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt @@ -172,7 +172,9 @@ internal class ComposeUiClusterRenderer( /* AndroidComposeView triggers LayoutNode's layout phase in the View draw phase, so trigger a draw to an empty canvas to force that */ view.draw(fakeCanvas) - val viewParent = (view.parent as ViewGroup) + val viewParent = + view.parent as? ViewGroup ?: return Bitmap.createBitmap(20, 20, Bitmap.Config.ARGB_8888) + .let(BitmapDescriptorFactory::fromBitmap) view.measure( View.MeasureSpec.makeMeasureSpec(viewParent.width, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(viewParent.height, View.MeasureSpec.AT_MOST),