1、kotlin协程使用过程中一般会加入suspend
关键字表明该方法需要单独线程处理
2、下载文件过程中如下
@GET
suspend fun downloadApk(@Url url: String): Call<ResponseBody>
在实际下载过程中会报错
Unable to create converter for retrofit2.Call<okhttp3.ResponseBody>
为啥?因为使用了suspend
关键字(最后才知道问题)
retrofit对suspend
的处理是视为同步操作,因此call就可以不需要了,可直接获取body数据。
@GET
fun downloadApk(@Url url: String): Call<ResponseBody>//正常操作
或者
@GET
suspend fun downloadApk(@Url url: String): ResponseBody//suspend关键字有额外处理
如此记录一下。。。。。避免再次踩坑