I am creating a custom Checkbox
within a Surface
which has a Modifier.clickable
:
Surface(
modifier = Modifier
.clickable(
enabled = enabled,
interactionSource = interactionSource,
indication = rememberRipple(),
role = Role.Checkbox,
onClick = { onCheckedChange(!checked) }
)
.then(modifier),
) {
Row {
Checkbox(checked = checked, onCheckedChange = {}, colors = colors)
Text(text = text ?: "")
}
}
When I try to build that, I get the Exception during IR lowering error
error:
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: /home/rene/AndroidStudioProjects/pass13/app/src/main/java/com/aresid/simplepasswordgeneratorapp/ui/widgets/Checkbox.kt
See the full stacktrace here.
Removing the Modifier.clickable
solves the build issue.
I already tried up-/downgrading some versions but nothing is working properly.
Currently, I am using those versions:
ext.versions = [
'compileSdk': 31,
'targetSdk' : 30,
'minSdk' : 26,
'kotlin' : '1.5.30',
'navigation': '2.3.5',
'compose' : '1.0.2'
]
If you are using Kotlin 2.0.+, you must use the Compose Compiler Gradle plugin for each module that uses compose.
Define the plugin is following in your libs.versions.toml
[versions]
.....
[plugins]
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
Add the plugin to the project root gradle file
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler) apply false
}
Then add this to each module gradle file:
alias(libs.plugins.compose.compiler)