1、关联源码
AS默认从当前工程最新SDK源码往下查找,有时源码不在默认位置,就需要手动关联到当前已有源码包去,下面是关联步骤:
a)到AS的数据目录.AndroidStuido2.2下找到jdk.table.xml文件,我的位置是C:\Users\Henry\.AndroidStudio2.2\config\options\jdk.table.xml
b)打开jdk.table.xml,xml节点结构如下:
<application>
<component name="ProjectJdkTable">
<jdk version="2">
<name value="Android API 8 Platform" />
<type value="Android SDK" />
<homePath value="C:\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://C:/Android/sdk/platforms/android-8/android.jar!/" />
<root type="simple" url="file://C:/Android/sdk/platforms/android-8/data/res" />
<root type="simple" url="jar://C:/Android/sdk/tools/support/annotations.jar!/" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root type="simple" url="file://C:/Android/sdk/docs/reference" />
</root>
</javadocPath>
<sourcePath>
<root type="composite" >
<root type="simple" url="file://C:\Android\sdk\sources\android-24"/>
</root>
</sourcePath>
</roots>
<additional jdk="1.8" sdk="android-8" />
</jdk>
</component>
</application>
在25-29行区域<sourcePath>标签即是源码的配置标签,在url属性中配置源码路径,不要求sdk版本与源码版本一致(3行),可错位配置源码,重启AS即可。