Android Studio 源码阅读
2020-08-06 本文已影响0人
洺优
还是以前做platform给惯的,调个环境都懒得不行,每次都搜索一遍可还行。。。
首先SDK Downloader 里面把需要的对应版本的源码下下来(对应compileSdkVersion)

理论上这样就可以了,在搜索源码的时候如果有什么需要设置的,Android Studio会提示,apply suggestion就好了。
在某些Studio版本可能还不行,那么我们照网路朋友教程来检查一下。
执行命令
cd ~/Library/Preferences/AndroidStudio4.1/options
进入配置目录。
其中我这里 AndroidStudio 版本为 4.1,如果你的版本为其他,上面的目录应该为 AndroidStudio 加上对应版本号。
然后打开 jdk.table.xml,里面包含各个 SDK 版本的配置。
假设你 AndroidStudio 提示的是 27 有问题,你查找 27。
可以看到
<jdk version="2">
<name value="Android API 29 Platform" />
<type value="Android SDK" />
<version value="java version "1.8.0_202"" />
<homePath value="$USER_HOME$/Library/Android/sdk" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar://$APPLICATION_HOME_DIR$/plugins/android/lib/androidAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/Library/Android/sdk/platforms/android-29/android.jar!/" type="simple" />
<root url="file://$USER_HOME$/Library/Android/sdk/platforms/android-29/data/res" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root url="file://$USER_HOME$/Library/Android/sdk/docs/reference" type="simple" />
</root>
</javadocPath>
<sourcePath>
<root type="composite">
<root url="file://$USER_HOME$/Library/Android/sdk/sources/android-29" type="simple" />
</root>
</sourcePath>
</roots>
<additional jdk="1.8" sdk="android-29" />
</jdk>
可以看看源码配置在不在
<sourcePath>
<root type="composite">
</root>
</sourcePath>
没有的话填上保存重启 AndroidStudio 就可以了。