I'm trying to find the source code for Android SDK classes such as View, Canvas, and Bundle. Where can I find the source code for these classes and is it even possible?
我正在尝试查找Android SDK类的源代码,例如View,Canvas和Bundle。我在哪里可以找到这些类的源代码,甚至可能吗?
1 个解决方案
#1
The source code for built-in classes (those that are part of the Android SDK) can be viewed by downloading the SDK source code using the SDK Manager.
可以使用SDK Manager下载SDK源代码来查看内置类(属于Android SDK)的源代码。
From within Android Studio, navigate to Tools -> Android -> SDK Manager. Once open, you'll need to download the Sources for Android SDK as shown below.
在Android Studio中,导航到工具 - > Android - > SDK Manager。打开后,您需要下载Android SDK的源代码,如下所示。
Once you have the sources downloaded, you can find the source code inside of the "sources" folder of your SDK (wherever that may be on your computer). Below I've added an image to show where you would find the View.java class inside of the SDK source files. To find other classes in the SDK, navigate to them using the package name as a hint to their location in the folder structure. (e.g. android.app.Activity -> android/app/Activity.java).
下载完源代码后,您可以在SDK的“sources”文件夹中找到源代码(无论您的计算机上是哪个位置)。下面我添加了一个图像,以显示您在SDK源文件中找到View.java类的位置。要在SDK中查找其他类,请使用包名称导航到它们,作为它们在文件夹结构中的位置的提示。 (例如android.app.Activity - > android / app / Activity.java)。
Also, if you download the source code for a specific version, then make that version your compileSdkVersion version in your build.gradle file, you can access source code from directly within Android studio by command clicking on the class name. So if you download the sources for API 21, then set your compileSdkVersion to be API 21 as shown below, you won't have to navigate your file system to find the file.
此外,如果您下载特定版本的源代码,然后在build.gradle文件中将该版本作为compileSdkVersion版本,则可以通过单击类名称直接在Android studio中访问源代码。因此,如果您下载API 21的源代码,然后将compileSdkVersion设置为API 21,如下所示,您将不必导航文件系统以查找文件。
#1
The source code for built-in classes (those that are part of the Android SDK) can be viewed by downloading the SDK source code using the SDK Manager.
可以使用SDK Manager下载SDK源代码来查看内置类(属于Android SDK)的源代码。
From within Android Studio, navigate to Tools -> Android -> SDK Manager. Once open, you'll need to download the Sources for Android SDK as shown below.
在Android Studio中,导航到工具 - > Android - > SDK Manager。打开后,您需要下载Android SDK的源代码,如下所示。
Once you have the sources downloaded, you can find the source code inside of the "sources" folder of your SDK (wherever that may be on your computer). Below I've added an image to show where you would find the View.java class inside of the SDK source files. To find other classes in the SDK, navigate to them using the package name as a hint to their location in the folder structure. (e.g. android.app.Activity -> android/app/Activity.java).
下载完源代码后,您可以在SDK的“sources”文件夹中找到源代码(无论您的计算机上是哪个位置)。下面我添加了一个图像,以显示您在SDK源文件中找到View.java类的位置。要在SDK中查找其他类,请使用包名称导航到它们,作为它们在文件夹结构中的位置的提示。 (例如android.app.Activity - > android / app / Activity.java)。
Also, if you download the source code for a specific version, then make that version your compileSdkVersion version in your build.gradle file, you can access source code from directly within Android studio by command clicking on the class name. So if you download the sources for API 21, then set your compileSdkVersion to be API 21 as shown below, you won't have to navigate your file system to find the file.
此外,如果您下载特定版本的源代码,然后在build.gradle文件中将该版本作为compileSdkVersion版本,则可以通过单击类名称直接在Android studio中访问源代码。因此,如果您下载API 21的源代码,然后将compileSdkVersion设置为API 21,如下所示,您将不必导航文件系统以查找文件。