Balloon: Crash Fatal Exception: java.lang.IllegalArgumentException The width of the balloon must bigger than zero.

Please complete the following information:

  • Library Version: com.github.skydoves:balloon-compose:1.6.5
  • Affected Device(s): image

Describe the Bug: I have a crash reported in Firebase. I cannot reproduce it. Attached the stacktrace from firebase. balloon crash stacktrace.txt

I have created this reusable view:

@Composable
fun SimpleTooltip(
    context: Context,
    showTooltip: Boolean = false,
    onTooltipDismiss: (() -> Unit)? = null,
    selectedElement: @Composable () -> Unit = {}
) {
    Balloon(
        balloonContent = {
            // Tooltip UI
        },
        builder = rememberBalloonBuilder {
            setWidth(BalloonSizeSpec.WRAP)
            setHeight(BalloonSizeSpec.WRAP)

            setArrowSize(10)
            setArrowPositionRules(ArrowPositionRules.ALIGN_ANCHOR)
            setArrowPosition(0.5f)

            setMarginHorizontal(8)

            setPadding(12)
            setCornerRadius(16f)
            setBackgroundColor(SharedRes.colors.surface.getColor(context))
            setBalloonAnimation(BalloonAnimation.ELASTIC)

            setIsVisibleOverlay(true)
            setOverlayColor(Color(SharedRes.colors.background.getColor(context)).copy(0.8f))
            setOverlayPadding(16f)

            setBalloonHighlightAnimation(BalloonHighlightAnimation.SHAKE)
            setOverlayShape(BalloonOverlayCircle(100f))
            setDismissWhenClicked(true)
        }
    ) { balloonWindow ->
        selectedElement.invoke()

        if (showTooltip) {
            balloonWindow.setOnBalloonDismissListener {
                onTooltipDismiss?.invoke()
            }

            balloonWindow.showAlignBottom()
        }
    }
}

Expected Behavior: The app should not crash.

If that helps, all the crashes have been mentioned as “Early crashes”, that means that they have occurred at the first 2" of the app launch. But the strange thing is that the class name is not from the name of the main Activity. 🤔

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

@kostapostolakis I’m happy to help out your team!

It seems that the crash has been resolved. We can close the issue and if it comes again, I will comment again to reopen it. Thank you very much for your support!

I think this is the problem. I managed to reproduce the crash when I have no views in balloonContent or the views in the balloonContent has not a specific width (for example a Spacer without specifying the width).

I will upload a new version and I will inform you as soon as possible if the crash is still appearing.

@kostapostolakis would you try with the solution below?

      content = { balloonWindow ->
  
          LaunchedEffect(Unit) {
           delay(100) // remove or not
            balloonWindow.showAlignStart()
          }
     }