Kotlin 中 Retrofit + coroutines + okhttp 使用

build.gradle

dependencies { 
   //retrofit + gson + coroutines
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
}

Retrofit 的当前版本已经支持 kotlin 协程的方式来调用

你可能感兴趣的:(kotlin,retrofit,okhttp)