android - java.lang.ClassNotFoundException : Didn't find class "kotlinx.coroutines.experimental.Deferred"

标签 android kotlin retrofit coroutine

我在使用带有改造的协程时遇到了这个问题,你能告诉我为什么会出现这个错误

java.lang.ClassNotFoundException:在路径上找不到类“kotlinx.coroutines.experimental.Deferred”:DexPathList[[zip 文件“/data/app/com.coroutines.retrofit.kotlin-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64,/system/lib64]]

当我使用以下依赖项时,

实现 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-experimental-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'

最佳答案

Add this dependency in your build.gradle : (remove experimental dependency for coroutine)

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

And add CoroutineCallAdapterFactory() for retrofit

addCallAdapterFactory(CoroutineCallAdapterFactory())

关于android - java.lang.ClassNotFoundException : Didn't find class "kotlinx.coroutines.experimental.Deferred",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53700414/

相关文章:

android - 将 Android 位图的一部分重叠绘制到自身上是否安全?

unit-testing - 如何使用 KotlinTest 库在测试方法中验证模拟接口(interface)?

annotations - 在 Kotlin 中注释属性时,注释的默认目标是什么?

android - 查询 2 个 GeoPoints 之间的位置

android - 将 Retrofit RestAdapter.LogLevel 设置为 FULL 以外的任何值都会导致 Empty Response Body

java - 我的 Retrofit call.enqueue() 方法被完全跳​​过,不知道为什么

java - 使用改造和 Dagger 我将如何创建一个可以轻松切换端点的应用程序?

android - 按下后退箭头时如何恢复上一个 Activity 的状态

android - RecyclerView插入/移除动画删除不需要的对象

android - 如何在安卓手机上安装所有应用程序