You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android(Kotlin+Compose)项目中Retrofit Gson转换器无法识别

无法识别GsonConverterFactory的原因及修复方案

你遇到的问题是依赖配置里存在两处拼写错误:

  • 包名拼写错误:com.squareaup 多了一个字母a,正确的包名是com.squareup
  • 依赖名称拼写错误:convertor-gson 使用了英式拼写,Retrofit官方依赖采用美式拼写converter-gson

替换为正确的依赖配置:

implementation("com.squareup.retrofit2:retrofit:2.9.0") // network calls
implementation("com.squareup.retrofit2:converter-gson:2.9.0") // json to object

重新同步项目后,就能正常导入GsonConverterFactory类了。

内容的提问来源于stack exchange,提问作者dipansh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 19:49:49