關於Android Studio匯入原始碼的問題解決
阿新 • • 發佈:2019-01-03
問題
ctrl + 右鍵 進入原始碼看不到詳細程式碼
方法體中顯示介樣內容:
throw new RuntimeException("Stub!");
上方提示介樣的錯誤:
Decompiled .class file, bytecode version XX(java X)
Sources for 'Android API 23 Platform' not found.
也就是介樣的錯誤(點選後面的超連結還不好使。。):
看了下SDK其實是有原始碼檔案的。
解決方法
- window使用者
C:\Users\username\.AndroidStudioXXX\config \options\jdk.table.xml
- Mac使用者
~/Library/Preferences/AndroidStudioXXX/options/jdk.table.xml
ps:AndroidStudioXXX 如果有多個,選擇你正在使用的版本
然後開啟。
再然後找到你錯誤提示的版本資訊那部分,如Android API 23 Platform:
<jdk version="2">
<name value="Android API 23 Platform" />
<type value="Android SDK" />
<homePath value="E:\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://E:/Android/sdk/platforms/android-23/android.jar!/" />
<root type="simple" url="file://E:/Android/sdk/platforms/android-23/data/res" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root type="simple" url="file://E:/Android/sdk/docs/reference" />
</root>
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional jdk="1.7" sdk="android-23" />
</jdk>
再再然後, 找到sourcePath標籤:
<sourcePath>
<root type="composite" />
</sourcePath>
下一步,像這個檔案裡面其他的版本一樣,加上一個子標籤:
<sourcePath>
<root type="composite" >
<root type="simple" url="file://E:/Android/sdk/sources/android-23" />
</root>
</sourcePath>
url裡面地址是你的原始碼的地址
ps:注意標籤範圍,別加錯了,格式不對也不行。尤其注意頭結點和根節點。
上面的完成以後,儲存一下,就可以重啟Android Studio了,然後問題就解決了~
ps:如果問題沒解決就,看一下加的路徑有沒有問題,或者格式加錯了。
參考連結:
第一個連結
第二個連結