• 川殇
    2019-05-31
    现在协程版本都1.2.1了,有些调用都变化了

    作者回复: 是的,视频录制是在一年多以前做的,那时候还没有协程正式版,没办法,不能更新

    
     1
  • Nate Robinson
    2019-06-20
    How to migrate Kotlin from 1.2 to Kotlin 1.3.0 then using async, launch...

    https://stackoverflow.com/questions/53125385/how-to-migrate-kotlin-from-1-2-to-kotlin-1-3-0-then-using-async-ui-and-bg-in-a

    这个link里面有介绍
    展开

    作者回复: 👍🏻

    
    
  • 书生依旧
    2019-02-20
    await 是会阻塞当前线程,这样写虽然网络请求是异步的,但是 await 必须要等到网络返回数据才会往下执行,还是会阻塞 UI 吧?

    作者回复: await的调用必须在suspend代码块内

    
    
  • Mr.T
    2018-12-14
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1'
    fun displayDashboard(mTextView: TextView) = runBlocking {
        launch {
            mTextView.text = withContext(Dispatchers.Default) {
                okHttpClient.newCall(request).execute().body()?.string()
            }
        }
    }
    展开
    
    
  • tiny
    2018-08-24
    依赖了协程的Android库以后,会报错,然后我从协程的github上找了demo,发现问题跟我的一样,怎么解?

    依赖:
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.25.0"

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.61"

    报错:
    Android部分:
    1、Program type already present: kotlinx.coroutines.experimental.internal.LockFreeMPMCQueue
    Message{kind=ERROR, text=Program type already present: kotlinx.coroutines.experimental.internal.LockFreeMPMCQueue, sources=[Unknown source file], tool name=Optional.of(D8)}

    2、Program type already present: kotlinx.coroutines.experimental.sync.MutexImpl$lockSuspend$$inlined$suspendAtomicCancellableCoroutine$lambda$1
    Message{kind=ERROR, text=Program type already present: kotlinx.coroutines.experimental.sync.MutexImpl$lockSuspend$$inlined$suspendAtomicCancellableCoroutine$lambda$1, sources=[Unknown source file], tool name=Optional.of(D8)}

    Java部分:
    1、com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/xxx/KotlinCoroutineDemo/app/build/intermediates/transforms/desugar/debug/16.jar

    2、com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.

    3、com.android.tools.r8.CompilationFailedException: Compilation failed to complete

    4、com.android.tools.r8.utils.AbortException
    展开

    作者回复: 可以run一下本视频中的示例代码,对照看看是不是配置或者gradle的问题

    
    
我们在线,来聊聊吧