【发布时间】:2020-04-08 05:32:49
【问题描述】:
我正在尝试调试我的协程,但放置在挂起函数中的断点不起作用。请帮助我理解原因。
使用 Android Studio。
好的,我从 viewModelScope 启动一个协程:
viewModelScope.launch(IO) {
when(val result = interactor.getAllWords()){...}
}
在getAllWords()我写道:
override suspend fun getAllWords(): WordResult {
val words = mutableListOf<Word>()
when (val wordsResult = getAllWordsWithoutFiltersApplying()) {}
...
return getWordsWithSelectedPattern()
我有两个挂起函数:getAllWordsWithoutFiltersApplying() 和 getWordsWithSelectedPattern()。我对它们都有一个断点,但它们没有在调试模式下触发。
同时,val words = mutableListOf<Word>() 行正在触发,当我在其行设置断点时。
而且,如果我将一些日志内容放入“取消跟踪”功能,它们就会起作用。我这么说是为了说明,挂起功能有效。断点不是。
我应该怎么做才能调试它们?
*已添加屏幕截图。查看左侧的图标行。为什么我的线路不可用?
【问题讨论】:
-
可以发
getAllWordsWithoutFiltersApplying()的全文吗?
标签: android-studio debugging kotlin kotlin-coroutines