报错:
JavaScript:
java.lang.NullPointerException: Can't toast on a thread that has not called Looper.prepare()
at com.android.internal.util.Preconditions.checkNotNull(Preconditions.java:167)
at android.widget.Toast.getLooper(Toast.java:185)
at android.widget.Toast.<init>(Toast.java:170)
at android.widget.Toast.makeText(Toast.java:498)
at android.widget.Toast.makeText(Toast.java:486)
at com.example.bandReader.MainViewModel$syncBook$2.invokeSuspend(MainViewModel.kt:642)
at com.example.bandReader.MainViewModel$syncBook$2.invoke(Unknown Source:8)
at com.example.bandReader.MainViewModel$syncBook$2.invoke(Unknown Source:4)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167)
at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
at com.example.bandReader.MainViewModel.syncBook(MainViewModel.kt:641)
at com.example.bandReader.MainViewModel.syncv2(MainViewModel.kt:778)
at com.example.bandReader.MainActivity$DetailScreen$5$2$4$1.invokeSuspend(MainActivity.kt:957)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@66bf1ee, androidx.compose.runtime.BroadcastFrameClock@bc0b68f, StandaloneCoroutine{Cancelling}@a477d1c, Dispatchers.IO]