Hello :slightly_smiling_face: Since I changed to version "beta03" I get the following error message ...
t
Hello 🙂 Since I changed to version "beta03" I get the following error message when I try to backpress in a suspend function. How can I fix this error?
java.lang.IllegalStateException: A MonotonicFrameClock is not available in this CoroutineContext. Callers should supply an appropriate MonotonicFrameClock using withContext.
Copy code
lifecycleScope.launch { bottomBarManager?.onBackPressed() }
super.onBackPressed()
i
launch { withContext(MonotonicFrameClock) {} }
🚫 1
t
@itnoles tried what you said.
Copy code
lifecycleScope.launch { withContext(MonotonicFrameClock) { bottomBarManager?.onBackPressed() }}
Type mismatch.
Required:
CoroutineContext
Found:
MonotonicFrameClock.Key
@julioromano this is not working for me. I use lifecyclescope instead of Coroutine scope as it is activity.
j
Sounds weird, generally lifecycleScope shouldn’t be used within composables.
t
We are not using in composable, we are using it in an activity
j
Too much context is missing, what are you trying to accomplish?
âž• 1
a
Can you post the code from
bottomBarManager.onBackPressed()
?
I'm guessing it performs animation internally, right?
d
I had this error when trying to close a drawer from a ViewModel.
The solution was to use a LaunchedEffect from compose.
Or some other coroutine launch from the compose scope.
Launching the coroutine from anywhere outside of compose results is this kind of error.
a
Yep. You always want to have your animations synchronized with the composition they're happening in. This is the mechanism for doing that.