“尚未应用待处理的组合物”例外是什么意思以及如何避免?

2024-03-29

我有一个正在运行的应用程序,但有时,由于我未知的原因,应用程序崩溃并显示以下消息:

java.lang.IllegalStateException:尚未应用挂起的组合

我无法在任何地方找到有关此异常发生的信息,而且我也不明白如何避免它。

编辑#1:经过一些研究和测试,我发现当我在 BottomNavigation 中的选项卡之间快速切换时会引发此异常(选项卡包含 LazyColumn)


由于我没有足够的声誉来撰写评论,因此我将其写在这里。也许对你有帮助

我今天遇到了同样的错误。如果我开始调试,并且我将大量日志记录行放入我的代码中,以了解到底是什么导致了这个问题。我弄清楚了是什么原因导致了这个错误。我的代码中存在实际问题,引发了异常(数组索引越界),但似乎某个地方的重组捕获了这个实际错误并引发了更通用的错误。

简化我的代码看起来像这样

val items = myViewModel.items.collectAsState().value
val focusRequesters = myViewModel.focusRequesters.collectAsState().value
LazyColumn() {
    items(items = items) { item ->
        // When I added new item then I got error in this line, 
        // because I forgot to add new focusRequester when I was adding new item. 
        // so it was actually array index out of bounds error
        val focusRequester = focusRequesters[item.position]
        ...
        // Code to show item
    }
    item {
         AddItemButton(myViewModel)
    }
}

它在日志中向我显示的实际错误是这个一般错误。

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.courtesy.test, PID: 27394
    java.lang.IllegalStateException: pending composition has not been applied
        at androidx.compose.runtime.CompositionImpl.drainPendingModificationsForCompositionLocked(Composition.kt:530)
        at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:567)
        at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:811)
        at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3583)
        at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:503)
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcomposeInto(SubcomposeLayout.kt:408)
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:383)
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:374)
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:363)
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$Scope.subcompose(SubcomposeLayout.kt:648)
        at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1.invoke(Scaffold.kt:316)
        at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1.invoke(Scaffold.kt:243)
        at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:68)
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1$measure$1.placeChildren(SubcomposeLayout.kt:527)
        at androidx.compose.ui.node.LayoutNode$layoutChildren$1.invoke(LayoutNode.kt:980)
        at androidx.compose.ui.node.LayoutNode$layoutChildren$1.invoke(LayoutNode.kt:965)
        at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2063)
        at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:112)
        at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:78)
        at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:52)
        at androidx.compose.ui.node.LayoutNode.layoutChildren$ui_release(LayoutNode.kt:965)
        at androidx.compose.ui.node.LayoutNode.onNodePlaced$ui_release(LayoutNode.kt:950)
        at androidx.compose.ui.node.InnerPlaceable.placeAt-f8xVGno(InnerPlaceable.kt:78)
        at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31)
        at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370)
        at androidx.compose.ui.node.OuterMeasurablePlaceable.placeOuterWrapper-f8xVGno(OuterMeasurablePlaceable.kt:158)
        at androidx.compose.ui.node.OuterMeasurablePlaceable.access$placeOuterWrapper-f8xVGno(OuterMeasurablePlaceable.kt:28)
        at androidx.compose.ui.node.OuterMeasurablePlaceable$placeAt$1.invoke(OuterMeasurablePlaceable.kt:146)
        at androidx.compose.ui.node.OuterMeasurablePlaceable$placeAt$1.invoke(OuterMeasurablePlaceable.kt:145)
        at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2063)
        at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:112)
        at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:78)
        at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release(OwnerSnapshotObserver.kt:59)
        at androidx.compose.ui.node.OuterMeasurablePlaceable.placeAt-f8xVGno(OuterMeasurablePlaceable.kt:145)
        at androidx.compose.ui.node.OuterMeasurablePlaceable.replace(OuterMeasurablePlaceable.kt:170)
        at androidx.compose.ui.node.LayoutNode.replace$ui_release(LayoutNode.kt:838)
        at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:262)
        at androidx.compose.ui.node.MeasureAndLayoutDelegate.access$remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:36)
        at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:201)
E/AndroidRuntime:     at androidx.compose.ui.platform.AndroidComposeView.onMeasure(AndroidComposeView.android.kt:773)
        at android.view.View.measure(View.java:25466)
        at androidx.compose.ui.platform.AbstractComposeView.internalOnMeasure$ui_release(ComposeView.android.kt:298)
        at androidx.compose.ui.platform.AbstractComposeView.onMeasure(ComposeView.android.kt:285)
        at android.view.View.measure(View.java:25466)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:145)
        at android.view.View.measure(View.java:25466)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
        at android.view.View.measure(View.java:25466)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.view.View.measure(View.java:25466)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
        at android.view.View.measure(View.java:25466)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at com.android.internal.policy.DecorView.onMeasure(DecorView.java:747)
        at android.view.View.measure(View.java:25466)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3397)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2228)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2486)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
        at android.view.Choreographer.doCallbacks(Choreographer.java:796)
        at android.view.Choreographer.doFrame(Choreographer.java:731)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

所以至少对我来说,当重组期间发生实际错误时,会抛出此错误。当然,如果它能向我显示实际错误而不是这个一般错误,那就太好了。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

“尚未应用待处理的组合物”例外是什么意思以及如何避免? 的相关文章

随机推荐

  • 如何使用 nhibernate 通过递归自连接 SQL 获得最佳性能

    我有一个带有parentId 的团队表 实体 它是一个自我加入到同一个表中的id 有一个名为 TopUnit 的属性 它将递归地继续调用 Parent 直到在 Team 实体上找到名为 IsTopUnit 的属性 使用 nhibernate
  • 如何制作基于Web的Python交互式shell

    网站如何喜欢https www pythonanywhere com try ipython https www pythonanywhere com try ipython work 他们可能会做几个exec命令 或与 ipython 交
  • 使用 WSGI 和 Python 3 提供静态文件

    使用 WSGI 和 Python 3 2 提供静态文件的最简单方法是什么 有一些用于 PEP 333 和 Python 2 的 WSGI 应用程序用于此目的 但是关于 PEP 3333 和 Python 3 的吗 我想使用 wsgiref
  • R:如何从数据框中获取正确的乳胶回归表?

    考虑下面的例子 inds lt c var1 var2 model1 lt c 10 2 0 00 0 02 0 3 model2 lt c 11 2 0 01 0 02 0 023 df df data frame inds model1
  • 如何创建接受泛型的无状态功能组件?

    Typescript 泛型可用于扩展接口 interface Sample1 p prop1 P interface Sample2 p p extends Sample1 p p prop2 string 但是当我尝试创建一个使用通用接口
  • 如何更改 JTextArea 中的文本颜色?

    我需要知道如何做到这一点 比方说 我有一个代码JTextArea像这样 LOAD R1 1 DEC R1 STORE M R1 ADD R4 R1 8 我想改变颜色LOAD DEC STORE and ADD涂成蓝色R1 R4涂成绿色M变为
  • 在 VBA 中将日期转换为文本

    我有一个数据集 其中包含文本值 例如 2016 年 3 月 现在我编写了以下代码来在我的报告表中复制此内容 DataFin Range E9 E9 DateSerial Year Date Month Date 0 DataFin Rang
  • Jackson JSON、不可变类和接口

    我正在使用 Jackson 的示例 并且在反序列化与不可变的类和接口一起使用时遇到了一些麻烦 下面是我的代码 package com art starter jackson starter import java io IOExceptio
  • 为什么在 Resharper/MSTest 下调试时引用的 dll 被锁定?

    我对汇编中的方法进行了集成测试A 集会A参考汇编B通过项目参考 我在 Resharper 6 1 单元测试场景中的 Visual Studio 2010 调试器下运行它们 测试引擎是微软原生的MSTest 我得到了臭名昭著的 该进程无法访问
  • 如何捕获 TimeConstrained 产生的中断?

    数学有CheckAbort允许捕获和处理用户生成的和编程的函数Aborts 但它不允许捕获由以下函数生成的中断TimeConstrained and MemoryConstrained TimeConstrained CheckAbort
  • M2Crypto:验证 DSA 签名

    我在使用 Python M2Crypto 验证 DSA 签名时遇到问题 签名是在 Java 中使用标准 java security Signature 类以及 Sun 的加密提供程序和 SHA1withDSA 算法指定生成的 这是一些 sh
  • 使用 SqlCommand 返回值

    我正在尝试获取 SQL 2008 服务器上存储过程的结果集和返回值 当我在sql management studio中运行proc时 我得到结果集和返回值 但是 当我尝试获取 C 4 0 中的值时 参数的值为 null 这是我的 C 代码
  • 通过 Grails 域标准在活动光标中出现 Mongo CursorNotFound 异常

    我正在使用 Grails 2 4 4 mongo 插件 3 0 2 MongoDB 2 4 10 使用远程数据库连接 grails mongo host 11 12 13 14 A remote server IP port 27017 d
  • 如何实现Flood-fill算法?

    我正在开发一个 Paint 应用程序 其中我正在实现类似于 MS Paint 应用程序的 BucketFill 功能 我使用一些 FloodFill 算法对其进行了编码 但填充颜色过程花费了太多时间 我不太确定其背后的原因可能是由于缓存内存
  • 标签文本中的 RGB 颜色效果,tkinter python

    您好 我只是在尝试一些代码 我正在尝试更改标签内文本的颜色 如物理键盘中的 rgb 颜色效果 使用以下代码我确实改变了颜色 但我正在尝试实现的目的是改变文本每个字母的颜色 但我不知道该怎么做 下面是我写的代码 import tkinter
  • 如何使用 WiX 将交互式用户添加到本地化 Windows 中的目录?

    如何添加瑞典语交互式用户 NT INSTANS INTERAKTIV 或英文交互用户 NT AUTHORITY INTERACTIVE 或任何其他本地化用户组write程序文件夹 ACL 的权限 这个问题实际上是 我如何使用安全对象 我无法
  • 在 AWS RDS 实例之间移动数据

    我需要在两个不同的 rds 实例上的相同 mysql 数据库之间移动数百万行 我想到的方法是这样的 use data pipeline to export data from the first instance to amazon s3
  • 在 R 中对非常大的数据集(180 万行 x 270 列)进行建模

    我正在研究一个视窗8操作系统带有8 GB 内存 我有一个数据框180 万行 x 270 列我必须对其执行glm logit 任何其他分类 我尝试使用 ff 和 bigglm 包来处理数据 但我仍然面临错误的问题 Error cannot a
  • 检查我的页面是否嵌入 iframe 中

    我想测试我的页面 php 是否嵌入到 iframe 中 以便实现不同的行为 知道如何测试这个 如果有帮助的话我也在使用 jQuery 添加 我特别感兴趣是否有一种方法可以在服务器上而不是在客户端使用 Javascript 来测试它 你可以使
  • “尚未应用待处理的组合物”例外是什么意思以及如何避免?

    我有一个正在运行的应用程序 但有时 由于我未知的原因 应用程序崩溃并显示以下消息 java lang IllegalStateException 尚未应用挂起的组合 我无法在任何地方找到有关此异常发生的信息 而且我也不明白如何避免它 编辑