https://kotlinlang.org logo
#compose
Title
# compose
n

natario1

05/03/2022, 3:52 PM
Trying to debug this crash where none of my files are in the stacktrace (see thread)… The only hint is the presence
androidx.compose.ui.platform.AndroidUiDispatcher
. Does this maybe mean that the crash happens in a compose effect? Or any other implication that could help debugging?
Copy code
2022-05-03 10:40:07.110 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: <http://my.app|my.app>, PID: 32505
    java.util.NoSuchElementException: Expected at least one element
        at kotlinx.coroutines.flow.FlowKt__ReduceKt.first(Reduce.kt:96)
        at kotlinx.coroutines.flow.FlowKt.first(Unknown Source:1)
        at kotlinx.coroutines.flow.FlowKt__ReduceKt$first$1.invokeSuspend(Unknown Source:13)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
        at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
        at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
        at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7870)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
r

Rob

05/03/2022, 3:54 PM
Look for where you're calling .first() on a Flow. The flow is not emitting any elements before completing.
Or actually it might be .reduce()
n

natario1

05/03/2022, 3:57 PM
Well I’m calling first in hundreds of places so if I could scope the issue down first (for example to compose effects), that would be great. Not using reduce at all
r

Rob

05/03/2022, 4:01 PM
From what I can tell, something is calling
.reduce()
on a
Flow<T>
. Maybe you're calling a library function that is using
.reduce()
.
r

reformator

05/05/2022, 6:50 PM
Maybe https://github.com/Anamorphosee/stacktrace-decoroutinator can help you to get more detailed stacktrace.
8 Views