Android Studio:如何附加 Android SDK 源?

Android Studio:如何附加 Android SDK 源?

问题描述:

如何将 Android SDK 源附加到 Android Studio?

How can I attach Android SDK sources to Android Studio?

当我打开其中一个 Android 类时,没有出现带有附加源"选项的未找到源"窗口.

When I open one of the Android classes, the "Sources not found" window with "Attach Sources" option doesn't appear.

还有什么方法可以做到这一点?

What is the other way to do this?

从工具栏菜单打开您的 sdk 管理器,并下载您的 build.gradle 文件中定义的 API 级别的Android SDK 源",如

Open your sdk manager from toolbar menus and download the "Sources for Android SDK" for the API level defined in your build.gradle file like

compileSdkVersion 19 // compile with API level 19

没有其他事情需要做.

注意:SDK 源仅适用于 API 级别 14 及更高级别.

Note : Sources for SDK is available only for API levels 14 and above.

更新(基于稳定版 3.2.1):

Google 改变了发送源的方法,让我们看看发生了什么变化.

Google changes the approach of shipping the sources, so lets see what changed.

前往以下位置

Preferences -> Apperance & Behaviour -> System Settings -> Android SDK

非常懒惰地在搜索和工作室中导航类型 SDK 将帮助您找到正确的位置.

Quite lazy to navigate type SDK in search and studio will help you to take to right place.

您可以阅读说明,主要说明要做什么.所以点击显示包详细信息"后,您将看到是否安装了源代码(如下图所示),如果没有安装,请安装即可.

You can read the description, says mostly what to do. So after clicking on "show package details" you will see whether sources are installed or not (as shown in below picture) if it is not installed do install and you are good.