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

Android Studio无法显示源文件(sources file)问题求助

Android Studio无法查看源文件的解决办法
  • 检查SDK源码是否已下载
    打开Android Studio的File > Settings > Appearance & Behavior > System Settings > Android SDK,切换到SDK Tools标签,找到对应API版本的Android SDK Sources for Android API xx,勾选后点击Apply完成下载。

  • 关联源码到目标库
    右键点击项目里无法查看源码的依赖,选择Library Properties,在弹窗中点击Attach Sources,可以直接选择已下载的SDK源码路径(通常在SDK目录/sources/android-xx),或者点击Download自动下载并关联。

  • 清理缓存重启AS
    点击File > Invalidate Caches...,勾选Clear file system cache and local history,再点击Invalidate and Restart,重启后重试查看源码。

  • 修正依赖配置
    打开Module级别的build.gradle,确保依赖写法是完整的,比如避免implementation 'xxx:xxx:xx.x.x@aar'这种仅引用aar的格式,改用不带@aar的implementation 'xxx:xxx:xx.x.x',这样才能正常关联源码。

  • 手动指定源码路径(特殊场景)
    若上述方法无效,找到对应库的jar文件右键选Add as Library,然后在Project Structure > Libraries里找到该库,点击+添加Sources路径,指向已下载的源码文件夹即可。

内容的提问来源于stack exchange,提问作者Mark Daniel Estorba

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 06:45:29