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

Android新建项目后无法导入Retrofit库的问题

解决Retrofit无法导入的问题

你的问题核心是Retrofit核心库与Gson转换器库的版本不匹配,当前retrofit:2.9.0和converter-gson:2.7.2版本不一致,导致依赖解析异常,无法正常导入库。

修正后的依赖配置

将converter-gson的版本改为与Retrofit核心库一致的2.9.0:

implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.squareup.picasso:picasso:2.8'

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

后续排查步骤

  • 同步Gradle项目:点击Android Studio右上角的「Sync Project with Gradle Files」按钮,等待依赖同步完成
  • 清理缓存并重启:依次点击File > Invalidate Caches...,选择「Invalidate and Restart」,清除IDE缓存后重启
  • 检查仓库配置:确保项目根目录的build.gradle文件中包含必要的仓库配置:
    repositories {
        mavenCentral()
        google()
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 14:50:33