依赖了协程的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的问题