美文网首页
AndroidStudio2.1无法查看Android源码

AndroidStudio2.1无法查看Android源码

作者: 路过麦田 | 来源:发表于2016-05-24 09:40 被阅读1089次

最近更新了AndroidStudio,升到了2.1,但是也同时出现了一些问题,比如查看Android源码的时候出现如下提示:

source not found.png

网上查了下也有相应的解决方案,写一下方便以后查看。

进入到/home/.AndroidStudio2.1/config/options/目录下,找到jdk.table.xml文件,用编辑器打开后,找到相应的平台:

<jdk version="2">
      <name value="Android API 23 Platform" />
      <type value="Android SDK" />
      <homePath value="$USER_HOME$/Apps/Developer/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://$USER_HOME$/Apps/Developer/android/sdk/platforms/android-23/android.jar!/" />
            <root type="simple" url="file://$USER_HOME$/Apps/Developer/android/sdk/platforms/android-23/data/res" />
          </root>
        </classPath>
        <javadocPath>
          <root type="composite">
            <root type="simple" url="file://$USER_HOME$/Apps/Developer/android/sdk/docs/reference" />
          </root>
        </javadocPath>
        <sourcePath>
          <root type="composite" />
        </sourcePath>
      </roots>
      <additional jdk="1.8" sdk="android-23" />
    </jdk>

可以看到<sourcePath>节点中的<root type="composite" /> 并没有源码的路径,这是android-23, 如果查看android-22的话,可以看到如下的代码:

<sourcePath>
    <root type="composite">
        <root type="simple" url="file://$USER_HOME$/Apps/Developer/android/sdk/sources/android-22" />
    </root>
</sourcePath>

url中的路径放到android-23中的同样位置,并将结尾的android-22改为android-23,重新打开AndroidStudio后,就可以查看Android源码了。

<jdk version="2">
      <name value="Android API 23 Platform" />
      <type value="Android SDK" />
      <homePath value="$USER_HOME$/Apps/Developer/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://$USER_HOME$/Apps/Developer/android/sdk/platforms/android-23/android.jar!/" />
            <root type="simple" url="file://$USER_HOME$/Apps/Developer/android/sdk/platforms/android-23/data/res" />
          </root>
        </classPath>
        <javadocPath>
          <root type="composite">
            <root type="simple" url="file://$USER_HOME$/Apps/Developer/android/sdk/docs/reference" />
          </root>
        </javadocPath>
        <sourcePath>
          <root type="composite">
            <root type="simple" url="file://$USER_HOME$/Apps/Developer/android/sdk/sources/android-23" />
          </root>
        </sourcePath>
      </roots>
      <additional jdk="1.8" sdk="android-23" />
    </jdk>

相关文章

网友评论

      本文标题:AndroidStudio2.1无法查看Android源码

      本文链接:https://www.haomeiwen.com/subject/rnhzrttx.html