java - 从 Java 类引用/单击时,Kotlin 类崩溃
问题描述
当我尝试单击将引用/调用 kotlin 类以运行的按钮时,应用程序崩溃。我尝试对其进行调试,但出现以下错误。我不知道错误要说什么,也许有人可以帮助我?:
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8798)
at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1606)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:380)
at android.view.View.requestLayout(View.java:25390)
at androidx.recyclerview.widget.RecyclerView.requestLayout(RecyclerView.java:4412)
at androidx.recyclerview.widget.RecyclerView$RecyclerViewDataObserver.triggerUpdateProcessor(RecyclerView.java:5582)
at androidx.recyclerview.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeInserted(RecyclerView.java:5557)
at androidx.recyclerview.widget.RecyclerView$AdapterDataObservable.notifyItemRangeInserted(RecyclerView.java:12278)
at androidx.recyclerview.widget.RecyclerView$Adapter.notifyItemInserted(RecyclerView.java:7464)
at com.example.astrocare.ui.MessagingAdapter.insertMessage(MessagingAdapter.kt:63)
at com.example.astrocare.ui.Chat_Bot_Main$customBotMessage$1$1.invokeSuspend(Chat_Bot_Main.kt:141)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)
解决方案
推荐阅读
- python - 数组和数字之间的最大值
- c# - 如何使用我的自定义方法扩展控制器类
- vue.js - vue 单文件组件中 sass 模板的 Webpack 编译问题
- javascript - 如果两个关联数组的一个字段值相同,则从两个关联数组中获取一个字段值
- ios - Xcode 中的 iOS 12.0.1 模拟器
- mongodb - 如何在 mongodb 中为聊天应用程序分组记录
- json - angular - 从 JSON 中读取属性名称作为列名,并在列中显示另一个属性值
- java - Lucene 特殊字符搜索
- javascript - 质疑 this.props.onSave 不是函数
- android - Play 商店是否会自动删除/暂停具有相同用户的应用程序?