Accepted answer

to attach source code for android.jar, you may follow the tutorial at the link below: make sure to choose the correct platform version.

if you meet difficutly with spinner, try to get the sample code and see how it works:

good luck. :)


this answer is quite out of date, please consider other answers.


i added appengine sdk and some other sources, and that destroyed my adt :-(

i saw that for android-16 and android-17, the platform libraries downloaded by sdk manager started going to ./sdk/sources whereas prior to my adding appenginge sdk, sdk manager sent platforms to ./sdk/platforms.

it looks like the change is as a result of the appengine sdk, but for adt, platform apis should def be going to ./sdk/platforms

the path ./sdk/sources seems like a more generic java location and is probably the 'correct' path. thus android, as usual, is the problem. i was pretty sure from this point forward, i would need both ./sdk/sources and ./sdk/platforms, depending on what i was compiling.

so, i moved everything from ./sdk/sources to ./sdk/platform, deleted ./sdk/sources and then created a link 'cd sdk && ln -s platform sources'

everything works now ;-)


for me the only solution which worked was the answer of fsbmain. kudos to him. i can't comment on his solution because of my low reputation counter. but i want to share my knowledge ;)

i'm working on windows and don't wanted to copy the whole source tree to another location. and copy again on updates etc. so i used the possibility to insert a symbolic link which works since windows vista like a charm (or like linux). for linux you have to look at the joe's comment under fsbmain's answer.

assuming you have the platform in d:\sdk\platforms\android-19. now you have to make a subdirectory sources and after that create a relative link to the real sources folder.

d:\sdk\platforms\android-19>mkdir sources
d:\sdk\platforms\android-19>cd sources
d:\sdk\platforms\android-19\sources>mklink /d android-19 ..\..\..\sources\android-19

now restart eclipse ... done!


what worked for me follows the answer found in murach's android programming. i got stuck trying to debug and tried to work it out for about 3 hours before turning to the next page (literally) where it said "sometimes eclipse will display a source not found message because...." (-headdesk-)

my solution was to turn on step filtering and add the packages that i wanted to skip when debugging. evidently, eclipse sometimes steps through all the source code libraries, when all you want is for it to step through your code. you can bypass this by adding the packages you want to skip to the filter. according to murach, you kinda just do it by trial and error, starting with selecting all packages and adding them. as you continue with debugging you might find you need to add more packages to the filter.

specific steps: 1. turn on step filtering; click the button in the toolbar on the top that looks like this: 2. go to window-->preferences, then in the preferences dialog, select java-->debug-->step filtering 3. select all packages. 4. to add additional filters, click "add filter", type the name of the package with a .* at the end, and click ok. murach recommends adding these common packages to begin: --android.*** --dalvik.* --libcore.* --org.apache.* so to add one of these packages, click "add filter", type "android.*", and click ok. i ended up having all of the following packages on my step filter preferences.

android.,,,,, com.sun., dalvik., java., javax., jrockit., libcore., org.apache., org.omg., sun., sunw.*, ((and this last one is a class, not a package)) java.lang.classloader

i had "use step filters" checked at the top of the dialog box, and "step through filters" checked at the bottom. click "apply", then "ok" to close the dialog. it should work.

good luck!


if adding folder android-sdks/sources/android-17 as external source doesn't work (as in my case) you can try to create folder android-sdks/platforms/android-17/sources/android-17 copy sources to it and restart eclipse (i have eclipse juno service release 1). only this way works for me.

steps to do this for android-17:

  1. go to the adroid-sdk install folder, for me it's d:\ws\android-sdks\
  2. copy android-17 sources folder from android-sdks\sources\android-17\ to the android-sdks\platforms\android-17\sources\ (your have to create folder sources here manually) folder so the final path to the sources must be the: android-sdks\platforms\android-17\sources\android-17\
  3. restart the eclipse, it must automatically attach sources for android-17

upd: the same solution with symlinks:

windows vista+ (thanks @saleemrashid1 for mentioning mklink in comments):

1. cd platforms\android-17
2. mklink /d "sources\android-17" "..\..\..\sources\android-17"

for unix-base oses (@joe comment):

it works fine to create the directory and symlink "sources/android-xx" to "../../../sources/android-xx":

mkdir platforms/android-19/sources && 
ln -s ../../../sources/android-19 platforms/android-19/sources/android-19. 


unless you need older api sources, you are probably better served by timmmm's answer. if you do need sources older than 14, read on...

in eclipse simply go to

help -> install new software

then add update site

and go through the motions to install it.

this will happily provide sources for all installed api versions and works very well for me. some more documentation is here

look for the heading android sources


this is now really easy!

go to window->android sdk manager and install "sources for android sdk".

now try to control-click some android identify, you will get the usual "no source attached" page. click "attach source" and get the option to select an external folder.

now browse to /home/me/android-sdks/sources/android-16 (or wherever your sdk is installed; this is the default), and hit ok.

it should think for a moment and then display the source! yeay!

Related Query

More Query from same tag