When we wanted to explore the API implementation of the Android Framework layer, although we checked the corresponding source in the SDK Manager, the reality was that some classes were not properly linked.
1. The first check in the configuration file is matched to/Users / [username] / Library/Application Support/Google/AndroidStudio4.1 / options/JDK table. The XML Will the source path of the directory be the corresponding path to compileSdkVersion in the Android SDK or project compileSdkVersion? (Search keywords for other operating systems)
If not, change the correct path, restart AndroidStudio, sync the entire project
2. If the above operation is still not linked to the source code, then this is probably normal. This is because the source downloaded through the SDK manager of AndroidStudio is not complete, for example:
Don’t believe you can go to/Users / [username] / Library/Android/SDK/sources/Android – 30 to search, also do not have this file.
At this point, I recommend a big kill, go firstsearchWhich package is this class under?
Such as the PathClassLoader. Java source code path is libcore dalvik/SRC/main/Java/dalvik/system /, so I will goSource code project corresponding moduleClone the entire directory.
Cut to the target branch, the libcore dalvik/SRC/main/Java/dalvik copied to the directory
/ Users / [username] / Library/Android/SDK/sources/Android – 30 / directory.
Restart Android Studio and sync the entire project. Something magical happened:
Click the corresponding parent class, you can jump normally.
Other required classes can be similar to the method, but also encounter local source only part, clone down is relatively complete, can directly overwrite or skip duplicate files
This approach is much more convenient than downloading the source code, configuring it, and compiling the source code. After all, I’m not doing source development, just to see how it works.