Android Studio: how to attach Android SDK sources?

Android Studio 3.2.1 reporting in: solved the issue by resetting SDK.

Preferences -> Appearance & Behavior -> System Settings -> Android SDK.

Click on Edit to the right of Android SDK location. Next, Next, Finish to complete the wizard and voila!


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

Nothing else needs to be done.

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

UPDATE ( Based on stable release 3.2.1):

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

Go to the following location

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

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

enter image description here

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.

enter image description here


I'm unable to find the aforementioned gui options in v8.11 on osx however grep-fu tells me:

config is stored in ~/Library/Preferences/AndroidStudioBeta/options/jdk.table.xml

After editing this file (with Studio stopped) and restarting source mapping works fine for me.

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>