Kotlin类在从Java类引用/单击时崩溃
当我尝试单击引用/调用kotlin类以运行的按钮时,应用程序崩溃。我试图调试它,但我得到了以下错误。我不知道错误在说什么,也许有人能帮我Kotlin类在从Java类引用/单击时崩溃,java,kotlin,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(Vi
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)
为了让其他人能够帮助您解决这个问题,最好在您的android项目中共享代码,包括参与的Java和Kotlin类。您甚至可以提供指向公共github回购的链接以获得最佳结果