Series of articles:

Android Studio associated with Android SDK source code (Windows&Mac)

In Android development process, if you want to further understand the touch event distribution, Message and other work mechanism, we need to look at the Android SDK source code, so how does Android Studio associate the source code?

  • Download the corresponding SDK source version

In Android Studio, click “Tools->SDK Manager “to enter the following image:

Each version of the SDK comes with the corresponding source code, Android 10.0 (API 29) is selected here. After the download is complete, the Installed state is displayed when you log in to the system again.

  • Check SDK source code

Now that the source code has been downloaded, how do we view it? Now we need to view the source code of the Activity. Quickly double click the “Shift” key on the keyboard to pop up the input box.Check the “Include non-project items” option in the upper right corner and enter the class to check: “Activity”,As you can see, we’ve found the Activity class file, which we just downloaded from API 29 source code.

  • View the SDK source code for the specified version

Now we are looking at the source code of API 29(Android 10.0), but now we want to look at some earlier versions such as API 28(Android 9) to compare the difference, how to do? You might be thinking, let’s go back to the previous steps and download the source code for API 28.

Search in Android Studio again

There is no API 28, there is only API 29. There is a lot of talk online about modifying the JDK. Table. XML file configuration

Our configuration is ok and does not need to be modified. Why can’t you check the source code in Android Studio? This is actually related to compileSdkVersion configured in build.gradle. We used to configure compileSdkVersion 29 and now we can configure compileSdkVersion 28Look again, you can find the Activity class under API 28 source codeOf course, we want to see the source code for API 28 and API 29 at the same time, but we don’t want to change the values in build.gradle. At this point we can create a temporary module as Library and change its build.gradle value to what we want.As shown above, we can switch between the source code for API 28 and API 29 at any time.

  • conclusion

  1. We don’t need to modify the jdK.table. XML file configuration when we associate the source code, it will be updated when we download the source code, or we can simply delete the file and it will be generated automatically the next time Android Studio restarts.
  2. This article demonstrates the operation of associated source code on Both Windows and Mac based on Android Studio 3.5 for Mac