developer tip

Android Studio : Android SDK 소스를 연결하는 방법은 무엇입니까?

optionbox 2020. 8. 8. 12:29
반응형

Android Studio : Android SDK 소스를 연결하는 방법은 무엇입니까?


Android SDK 소스를 Android Studio에 어떻게 연결할 수 있습니까?

Android 클래스 중 하나를 열 때 "소스 첨부"옵션이있는 "소스를 찾을 수 없음"창이 나타나지 않습니다.

이를 수행하는 다른 방법은 무엇입니까?


툴바 메뉴에서 sdk 관리자를 열고 다음과 같이 build.gradle 파일에 정의 된 API 수준에 대한 "Sources for Android SDK"를 다운로드합니다.

compileSdkVersion 19 // compile with API level 19

다른 작업은 수행 할 필요가 없습니다.

참고 : SDK 용 소스는 API 레벨 14 이상에서만 사용할 수 있습니다.

업데이트 (안정적인 릴리스 3.2.1 기준) :

Google은 소스 배송 방식을 변경하므로 변경된 사항을 살펴 보겠습니다.

다음 위치로 이동

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

SDK검색 및 스튜디오에서 유형을 탐색하기가 상당히 게으 르면 올바른 위치 로 이동하는 데 도움이됩니다.

여기에 이미지 설명 입력

설명을 읽을 수 있으며 대부분해야 할 일을 말합니다. 따라서 "패키지 세부 정보보기"를 클릭하면 소스가 설치되었는지 여부를 볼 수 있습니다 (아래 그림 참조). 설치되지 않은 경우 설치를 수행하면 좋습니다.

여기에 이미지 설명 입력


Android Studio 3.2.1보고 : SDK를 재설정하여 문제를 해결했습니다.

환경 설정-> 모양 및 동작-> 시스템 설정-> Android SDK.

Android SDK 위치 오른쪽 에있는 편집클릭합니다 . 다음, 다음, 마침 마법사를 완료하고 짜잔!


osx의 v8.11에서 앞서 언급 한 GUI 옵션을 찾을 수 없지만 grep-fu가 알려줍니다.

구성은 ~ / Library / Preferences / AndroidStudioBeta / options / jdk.table.xml에 저장됩니다.

이 파일을 편집하고 (Studio가 중지 된 상태에서) 소스 매핑을 다시 시작하면 잘 작동합니다.

diff --git a/options/jdk.table.xml b/options/jdk.table.xml
index 0112b91..33828b8 100644
--- a/options/jdk.table.xml
+++ b/options/jdk.table.xml
@@ -76,7 +76,7 @@
         </javadocPath>
         <sourcePath>
           <root type="composite">
-            <root type="simple" url="file:///Applications/Android Studio.app/sdk/sources/android-19" />
+            <root type="simple" url="file:///Users/tehdawgz/dev/android-sdk/sources/android-19" />
           </root>
         </sourcePath>
       </roots>

나를 위해 2016/08/29 android studio 2.1.3을 실행 중입니다.

나는 소스가 공개되기 전에 api 24를 다운로드하고 컴파일하고있었습니다. 나는 그들이 릴리스되었으므로 이제 출처를 지적하고 싶습니다. SDK 관리자에서 소스를 다운로드 한 후 Android Studio를 다시 시작하면 작동하지 않았습니다.

SDK 관리자에서 SDK 위치를 편집하는 것처럼 행동해야했습니다. 그렇게했을 때 대화 상자에서 '다음'을 클릭하고 sdk 항목을 자동으로 다시 인덱싱 할 수있었습니다.

SDK 위치 편집 버튼 다음으로 클릭 할 곳


gdawg의 솔루션은 Windows 10 및 Android Studio 2.0에서도 저에게 효과적이었습니다. jdk.table.xml 파일이있는 작은 수정으로

C : \ Users \ {USER_NAME} \. AndroidStudio2.0 \ config \ options \ jdk.table.xml


Not sure why the accepted answer only seems to work with API level 19. I was able to attach SDK sources for API level 15 by explicitly providing the source path for the SDK. Here's what I did:

  1. Make sure I've downloaded the desired SDK sources and setup my build.gradle with the desired API level.
  2. In the Project window on the left, select the External Libraries drop-down.
  3. Right click the menu item and select Open Library Settings.
  4. Click the Sourcepath tab and use the + icon at the bottom left to link to the desired SDK sources (should be in something/sdk/sources)

In android studio 0.8.6(Beta) (OSX 10.9.4), it seems that you can view the android source code directly without attaching the Sources manually.

The prerequisite is you should download "Sources for Android SDK" in "SDK Manager" and restart "Android Studio"


Just follow these steps: Settings --> Android SDK --> Launch Standalone SDK Manager --> download your needed SDK sources(in every Anroid Version's Sources for Android SDK) --> restart your Android Studio. If above don't help, make sure you have downloaded the required SDK sources, and reset the Android SDK Location to refresh. I hope it helps.


I didn't know what menu step 3 of sfridman's answer was referring to. Another way I managed to get to the source I was interested in was after Android Studio had brought up the .class I wanted to dive into:

Breadcrumbs to .class 파일

I could then right click on that breadcrumb and choose "Jump to source":

여기에 이미지 설명 입력

It seemed to find it automatically from doing that, probably because I had installed the source via the Android SDK manager as described elsewhere.


First, check you have already load source.

then reset Android SDK Location at settings.

I solved my problem by above method.


The only thing that worked for me was:

  • Open the Android SDK Manager (Tools -> Android -> SDK Manager -> Launch Standalone SDK Manager)
  • uninstall all the SDK Platform and Sources for Android SDK (from all API levels)
  • restart Android Studio

Upon restart Android Studio will pop a wizard because no SDK is installed: install the SDK Platform and sources for the currently used API level.


In Android Studio 2.3.3 on Windows 7, I had the problem that the already downloaded source files für API-Level 26 in folder SDK\sources\android-26 were not recognized. Using "File | Invalidate Caches / Restart" solved the issue for me.


나를 위해 다운로드 및 새로 고침은 도움이되지 않았습니다. 나는 소스를 선택하려고했지만 여전히 같은 문제입니다. 그래서 캐시 무효화 / 다시 시작을했습니다. 이제 작동합니다.

jdk.table.xml 파일을 편집하려고했지만 android-26에 대한 항목이 없었고 android-25까지만 있었기 때문에 해당 파일을 편집하지 않기로 결정했습니다.


2019 년 9 월 8 일에는 이러한 소스를 사용할 수 있습니다.

sources;android-15
    Description:        Sources for Android 15
    Version:            2

sources;android-16
    Description:        Sources for Android 16
    Version:            2

sources;android-17
    Description:        Sources for Android 17
    Version:            1

sources;android-18
    Description:        Sources for Android 18
    Version:            1

sources;android-19
    Description:        Sources for Android 19
    Version:            2

sources;android-20
    Description:        Sources for Android 20
    Version:            1

sources;android-21
    Description:        Sources for Android 21
    Version:            1

sources;android-22
    Description:        Sources for Android 22
    Version:            1

sources;android-23
    Description:        Sources for Android 23
    Version:            1

sources;android-24
    Description:        Sources for Android 24
    Version:            1

sources;android-25
    Description:        Sources for Android 25
    Version:            1

sources;android-26
    Description:        Sources for Android 26
    Version:            1

sources;android-27
    Description:        Sources for Android 27
    Version:            1

sources;android-28
    Description:        Sources for Android 28
    Version:            1

다음과 같이 나열 할 수 있습니다. ./pathtoandroidsdk/tools/bin/sdkmanager --list --verbose --no_https

예를 들어 다음으로 설치하십시오. ./pathtoandroidsdk/tools/bin/sdkmanager "sources;android-28"

Android Studio에서 다운로드 할 필요가 없습니다.

Android Studio의 설정 지침

build.gradle에서 원하는 소스를 포함 할 올바른 SDK 버전을 설정합니다.

android {
    compileSdkVersion 28
    ...

변경 사항을 적용하려면 IDE를 다시 시작하십시오.

참고 URL : https://stackoverflow.com/questions/21221679/android-studio-how-to-attach-android-sdk-sources

반응형