我正在使用Crashlytics监控我的应用程序,我可以看到一些用户出现了这样的崩溃:

Fatal Exception: java.util.ConcurrentModificationException:
       at java.util.ArrayList$Itr.next(ArrayList.java:860)
       at kotlinx.coroutines.flow.FlowKt__BuildersKt$asFlow$$inlined$unsafeFlow$3.collect(SafeCollector.common.kt:181)
       at kotlinx.coroutines.flow.FlowKt__BuildersKt$asFlow$$inlined$unsafeFlow$3$1.invokeSuspend(SafeCollector.common.kt:1)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:1)
       at kotlinx.coroutines.flow.internal.SafeCollector.invokeSuspend(SafeCollector.kt:1)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:1)
       at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:1)
       at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:100)
       at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:100)
       at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:33)
       at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:26)
       at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:26)
       at kotlinx.coroutines.android.HandlerContext$scheduleResumeAfterDelay$$inlined$Runnable$1.run(HandlerContext.java:169)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8757)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

问题是,这个日志(log)并没有指向我的应用程序代码中的任何地方. 看起来我有一些并发的数组修改,但我不知道它可能在哪里.

如果重要的话,我确实会使用防范规则和最小化启用.我仍然会假设坠机指向我的包裹中的某个地方.

你知道我该怎么投资这个吗? 谢谢

推荐答案

我建议在所有地方查找,如果您在项目中使用.asFlow()或其他流构建器,请将所有那些流的collect或其他终端操作符(如first()single())包装在try/Catch中,并在Catch中添加一个定义日志(log).

Android相关问答推荐

编写Landscape BoxWithRequests具有错误的高度.(aspectRatio matchHeight约束第一次未按预期工作)

如何将结果从viewModelScope传递到活动

合成-删除图像的部分背景

在模块中找到重复的类com.google.Firebase.auth.ktx.AuthKt||Android Studio

尽管我们不再使用GCM SDK,但应用程序已被标记为使用GCM SDK

Jetpack Compose主导航中的全屏图标列表

Hilt+Worker NoSuchMethodException:<;init>;[class android.content.Context,class androidx.work.WorkerParameters]

如何正确创建可拖动的浮动视图?

闪屏 API 无法在 Android 12 上运行(API 31、32)

当 EditText 用于在 android studio 中将字符串发送到 firebase 时,仅允许安全调用错误

我如何比较多个时间范围并在 Android Compose 中并排显示它们

NFC getNdefMessage 在 Android 13 上写入标签后返回 null

Visual Studio 无法在 Android 上编译 .NET MAUI 项目

获取 ArithmeticException:除以零,但我没有在任何地方除以零

在 Jetpack Compose 中清除列表时可组合不重组

try 使用 ViewPager2 实现滑动视图时出现类型不匹配错误

删除项目时延迟列不更新

jetpack compose 中的可点击指示是什么?

Android Material Date Range Picker - 如何仅更改所选范围日期的文本 colored颜色 ?

Google Play 服务登录在 Unity Android 上无法正常运行