Why is my @Composable function in Jetpack Compose called after onResume instead of onCreate?
I’m learning how to develop an Android app using Jetpack Compose, and I’m currently working through understanding the activity lifecycle. I noticed an unexpected behavior: my @Composable
function is being called after the onResume
method, instead of right after onCreate
.
java.lang.IllegalStateException: CompositionLocal LocalLifecycleOwner not present
I get an java.lang.IllegalStateException: CompositionLocal LocalLifecycleOwner
not present error when I collectAsState()
or collectAsStateWithLifecycle()
. I do not know what is wrong. This previously worked, however since I made a switch and some dependencies update it stopped working. The error is as follows: