android studio中关联SDK源码

每次当我们更新完SDK后,想看SDK源码时,打开的源文件经常是不带注释的.class文件,虽然SDK已更新,但Source资源经常没及时更新,此时我们可以先关联低版本的可用的Source源码资源,如何关联呢?

首先我们先找到这个目录:

C:\Users\用\.AndroidStudio2.3\config\options

然后找到jdk.table.xml文件,这个文件可以进行关联源码配置,
接下来我们可以通过对比两个最近的配置项API-25与API-26:

    <jdk version="2">
      <name value="Android API 25 Platform" />
      <type value="Android SDK" />
      <homePath value="D:\Android\sdk" />
      <roots>
        <annotationsPath>
          <root type="composite">
            <root type="simple" url="jar://$APPLICATION_HOME_DIR$/plugins/android/lib/androidAnnotations.jar!/" />
          </root>
        </annotationsPath>
        <classPath>
          <root type="composite">
            <root type="simple" url="jar://D:/Android/sdk/platforms/android-25/android.jar!/" />
            <root type="simple" url="file://D:/Android/sdk/platforms/android-25/data/res" />
          </root>
        </classPath>
        <javadocPath>
          <root type="composite">
            <root type="simple" url="http://developer.android.com/reference/" />
          </root>
        </javadocPath>
        <sourcePath>
          <root type="composite">
            <root type="simple" url="file://D:/Android/sdk/sources/android-25" />
          </root>
        </sourcePath>
      </roots>
      <additional jdk="1.8" sdk="android-25" />
    </jdk>
    <jdk version="2">
      <name value="Android API 26 Platform" />
      <type value="Android SDK" />
      <homePath value="D:\Android\sdk" />
      <roots>
        <annotationsPath>
          <root type="composite">
            <root type="simple" url="jar://$APPLICATION_HOME_DIR$/plugins/android/lib/androidAnnotations.jar!/" />
          </root>
        </annotationsPath>
        <classPath>
          <root type="composite">
            <root type="simple" url="jar://D:/Android/sdk/platforms/android-26/android.jar!/" />
            <root type="simple" url="file://D:/Android/sdk/platforms/android-26/data/res" />
          </root>
        </classPath>
        <javadocPath>
          <root type="composite">
            <root type="simple" url="http://developer.android.com/reference/" />
          </root>
        </javadocPath>
        <sourcePath>
        //这块没有补全
          <root type="composite" />
        </sourcePath>
      </roots>
      <additional jdk="1.8" sdk="android-26" />
    </jdk>

通过对比可以发现sourcePath处标签不同,API-26没有指定源码资源路径,我们可以把API-25中的资源路径片段替换API-26中的,即把API-26处的:

    <sourcePath>
          <root type="composite" />
        </sourcePath>

替换为:

        <sourcePath>
          <root type="composite">
            <root type="simple" url="file://D:/Android/sdk/sources/android-25" />
          </root>
        </sourcePath>

最后再重启下android studio即可。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值