Unresolved reference: launch

前端 未结 4 524
孤独总比滥情好
孤独总比滥情好 2021-02-05 00:58

Trying to run some examples for Kotlin coroutines, but can\'t build my project. I\'m using the latest gradle release - 4.1

Any suggestions what to check/fix?

Her

4条回答
  •  -上瘾入骨i
    2021-02-05 01:47

    Like already answered in the comments, the import is missing for the kotlinx.coroutines.experimental.* package. You can have a look at my examples at GitHub if you like.

    import kotlinx.coroutines.experimental.*
    
    fun main(args: Array) {
    
        launch(CommonPool) {
            delay(1000)
            LOG.debug("Hello from coroutine")
        }
    
    }
    

提交回复
热议问题