1. 程式人生 > >Android Studio 檢視不到SDK原始碼解決辦法

Android Studio 檢視不到SDK原始碼解決辦法

  在使用 Android Studio 開發時,我們需要檢視SDK的原始碼,但是有時候看到的原始碼是類似這樣的提示,

  1. Sources for Android API 24 Platfrom not found  

如果我們沒有下載SDK的原始碼,點選Download提示,便會下載某個版本的SDK原始碼。下載完成,重啟 Android Studio後,檢視SDK某個類的原始碼,還是提示,

  1. Sources for Android API 24 Platfrom not found  
點選Download或者Refresh,都不起作用,但是很明顯,SDK的原始碼已經下載了,為何還是這樣?解決方法,需要關聯已經下載的原始碼。具體解決步驟如下,

需要我們修改jdk.table.xml檔案來配置原始碼路徑,

1.找到jdk.table.xml

windows平臺下,該檔案路徑是  “C:\Users\Administrator\.AndroidStudio2.1\config\options”,其中AndroidStudio2.1為你的AndroidStudio的版本。

2.新增相應的程式碼,

   使用文字編輯開啟jdk.table.xml,在相應的SDK版本的尾部新增SDK原始碼的路徑,例如,


新增如下程式碼,

  1. <sourcePath>
  2.          <roottype="composite"
    >
  3.            <roottype="simple"url="file://D:/Users/Administrator/AppData/Local/Android/sdk/sources/android-24"/>
  4.          </root>
  5.        </sourcePath>

一定要記得標籤的格式。

3.重啟Android Studio即可。