Encountering Backend Internal error with Jetpack Compose clickable modifier in custom Checkbox

I’m stuck with a problem in my Android app. I made a custom Checkbox using Jetpack Compose. It’s inside a Surface with a clickable modifier. But when I try to build it, I get a weird error: Exception during IR lowering.

Here’s a simplified version of my code:

CustomSurface(
    onTap = { toggleCheckbox() },
    isEnabled = canInteract
) {
    RowLayout {
        CustomCheckbox(isSelected = isChecked)
        CustomText(content = label)
    }
}

The error goes away if I remove the clickable part. I’ve tried changing versions, but no luck. Right now, I’m using Kotlin 1.5.30 and Compose 1.0.2.

Any ideas on how to fix this? I’m really scratching my head here. Has anyone run into something similar?

hey there! have you tried using a different layout? sometimes Row() or Column() can be more forgiving than custom layouts. also, whats your compileSdkVersion? i had similar weirdness and bumping it up helped. curious to hear if you’ve experimented with different composables or layouts? maybe theres a simpler way to achieve what youre after?

I’ve encountered a similar issue before, and it can be quite frustrating. One possible solution is to use the clickable modifier directly on the CustomSurface instead of using onTap. This approach often resolves the IR lowering exception. Try modifying your code like this:

CustomSurface(
modifier = Modifier.clickable(
enabled = canInteract,
onClick = { toggleCheckbox() }
)
) {
RowLayout {
CustomCheckbox(isSelected = isChecked)
CustomText(content = label)
}
}

If this doesn’t work, consider updating your Compose version to the latest stable release. Newer versions often include bug fixes for such issues. Also, ensure that all your Compose-related dependencies are using consistent versions to avoid conflicts.

yo, that error sounds like a pain! have u tried wrapping ur CustomSurface in a Box composable? sometimes that helps with weird click issues. also, double-check ur gradle dependencies - mismatched versions can cause funky errors. if nothing else works, maybe try a different approach entirely? like using a regular Checkbox with a custom look?