I updated a project from Jetpack compose 1.0.0 to 1.2.1. Therefore I increased the version to 1.2.1 for following dependencies:
// ***** UI & Jetpack Compose *****
implementation("androidx.compose.ui:ui:${SharedVersions.jetpackCompose}")
// ViewBinding support to integrate xml views via AndroidView()
implementation("androidx.compose.ui:ui-viewbinding:${SharedVersions.jetpackCompose}")
// Tooling support (Previews, etc.)
implementation("androidx.compose.ui:ui-tooling:${SharedVersions.jetpackCompose}")
// Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
implementation("androidx.compose.foundation:foundation:${SharedVersions.jetpackCompose}")
// Material Design
implementation("androidx.compose.material:material:${SharedVersions.jetpackCompose}")
// Integration with observables
implementation("androidx.compose.runtime:runtime-livedata:${SharedVersions.jetpackCompose}")
implementation("androidx.compose.runtime:runtime-rxjava2:${SharedVersions.jetpackCompose}")
and set
composeOptions {
kotlinCompilerExtensionVersion = "1.3.2"
}
Due to the dependencies/requirements of jetpack compose 1.2.1 I had to update following parts in my application to get it to compile:
compileSdk from 31 to 32
targetSdk from 31 to 32
gradle android plugin from 7.2.2 to 7.3.0
gradle 7.3.3 to 7.4.0
kotlin from 1.5.10 to 1.7.20
and minor code migrations to support update the new kotlin version.
After that the application compiles but it crashes on first start with:
ClassCastException: androidx.compose.runtime.internal.ComposableLambdaImpl cannot be cast to kotlin.jvm.functions.Function
The crash occurs when calling a function similiar to this:
fun <D> NavGraphBuilder.createAppNavGraphComposableDataAware(
route: String,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
content: @Composable (backStackEntry: NavBackStackEntry, data: D) -> Unit
) {
addDestination(Destination(provider, content as as @Composable (NavBackStackEntry, Any?) -> Unit)
}
Any clues what changed inside the jetpack compose libs or compiler? Does anyone else has problems similiar to this when using Composable Lambdas?