提问者:小点点

java.lang.ClassNotFoundException:未找到类“kotlinx.coroutines.experimental.deferred”


我在使用coroutine时遇到了这个问题,你能让我知道为什么我会出现这个错误吗

java.lang.ClassNotFoundException:在路径:DexPathList[[zip file“/data/app/com.coroutines.reverfit.kotlin-1/base.apk”],NativeLibraryDirectories=[/vendor/lib64,/system/lib64]]上找不到类“kotlinx.coroutines.experimental.deferred”

当我使用下面的依赖项时,

实现'com.jakewharton.reverfit:reverfit2-kotlin-coroutines-experiment-adapter:1.0.0'

实现“org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1”实现“org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1”

kotlin版本为:ext.kotlin_version='1.3.10'


共2个答案

匿名用户

在您的构建中添加此依赖项。Gradle:(删除coroutine的实验性依赖项)

dependencies {
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'
    implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
}

并添加CoroutineCallAdapterFactory()进行改进

addCallAdapterFactory(CoroutineCallAdapterFactory())

匿名用户

我也面临着同样的问题,那就是杰克沃顿的图书馆问题。它在内部使用实验参考。

使用实现“com.jakewharton.reverfit:reverfit2-kotlin-coroutines-experiment-adapter:1.0.0”

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/coroutines/experimental/Deferred;
    at com.jakewharton.retrofit2.adapter.kotlin.coroutines.experimental.CoroutineCallAdapterFactory.get

此库已弃用。下面是git库页面中的解决方案

此库已弃用。请迁移到改型2.6.0或更新版本及其内置的挂起支持