I am facing this issue when using coroutine with retrofit, can you please let me know why i am getting this error
java.lang.ClassNotFoundException: Didn't find class "kotlinx.coroutines.experimental.Deferred" on path: DexPathList[[zip file "/data/app/com.coroutines.retrofit.kotlin-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
while i am using the below dependencies,
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-experimental-adapter:1.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1'
and the kotlin version is : 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())
I am facing the same problem, it is the Jake Warton's library problem. It is using experimental references internally.
Using implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-experimental-adapter:1.0.0'
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/coroutines/experimental/Deferred;
at com.jakewharton.retrofit2.adapter.kotlin.coroutines.experimental.CoroutineCallAdapterFactory.get
This library is deprecated . Here is the solution from the library's page on git
This library is deprecated. Please migrate to Retrofit 2.6.0 or newer and its built-in suspend support
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With