Accepted answer

after downloading the support package from the android sdk manager, you can find the source code of support package in folder <android-sdks>/extras/android/support/v4/src.


the process of attaching the src and doc from build path works for some and it doesn't for some (like me). some key things to keep in mind

  1. make sure you are in package explorer, not project navigator.

  2. if you have put your android-support-v4.jar in libs folder under your project. great.

  3. right click the jar, build path.. add to path. (if add to path does not show up then its already added. you will see configure path..)

  4. as the result of step 3, a new folder called referenced libraries will appear in package explorer tree. open that tree, find the android-support-v4.jar there. right click on this jar in the referenced libraries, properties. then set the java source attachment and javadoc location there.

  5. you are done.

the path for my java source attachment.(its external location)


i used the android website doc for java doc location


i found this for me:

for main lib: android.jar:

src: sdk/sources/android-19 doc: sdk/docs/reference/

for support lib: android-support-v4.jar: (before this we should add android-support-v4.jar like external jar (project properties -> java build path -> libraries, then in tab ‘order and export’ pull up this library before android private libraries)):

src: sdk/extras/android/support/v4/src/java doc: (not sure)


after you have updated the sdk and downloaded documentations in it:

  • import support library project to package explorer.
  • create a folder in the library and name it something like ext-jars.
  • move android-support-v4.jar to ext-jars folder.

    enter image description here

  • right click on the project and click on properties.
  • click on java build path in the left menu then select libraries tab.
  • click on add jars... then expand the project and select the jar file you already moved to folder ext-jars.

enter image description here

  • expand the added jar and select source attachment then click on edit.
  • select external location then click on external folder...
  • choose the source folder for the support v4 which is located in [sdk-path]/extras/android/support/v4/src

enter image description here

  • select javadoc location click on edit then select javadoc url then click on browse... and choose the javadoc location for support v4 which is located in [sdk-path]/docs/reference/

enter image description here - select order and export tab and check the android-support-v4.jar you just added.

i suggest you also clean the project and reopen the eclipse.


i just remove the auto generated one , then manual add it as a referencde libraries.

first open a class, the ide will ask you to change attached source.


for those who like the standard to have the jar file of the source code, which makes it more convenient for source control and sharing the project.

for example:


it is simple to create the source jar file and attach it:

  1. cd to path_to_android_sdk/extras/android/compatibility/v4/
  2. use your favorite zip program such as 7-zip to create a zip file and name it android-support-v4-src.jar. the first folder in the jar should be /scr.
  3. copy the file to your project, in this example it is in the same folder as the code jar.
  4. in eclipse attach the source jar in project properties.


referencing the accepted answer, it is also possible to attach the source straight from the directory without building a .jar file. from the java build path / libraries tab, expand android-support-v4.jar, highlight "source attachment", click "edit...", "external folder..." then point to (android-sdk)\extras\android\support\v4.

this was tested using eclipse indigo.

from the comments:

the problem of being unable to add source to the support library seems to occur if your support library is located in the "android dependencies" folder of your project. the workaround is from the same "java build path / libraries" tab click "add external jars..." and find the .jar file in your (android-sdk)\extras\android\support\v4 path. it will then appear in your project setup under a new "referenced libraries" folder.


here the solution to attache the source of the support library in eclipse juno

i suppose that your project already has android-support-v4.jar in your "build path", under "android dependencies", but you cannot attach the sources directory to it. (the "source attachment" said "non modifiable"). solution:

  • goto "configure build path"
  • add external jars > yourproject/libs/android-support-v4.jar (i know your project had already referenced to it but don't worry, just add it again).
  • expand jar and attach source to the external jar: android-sdk/extras/android/support/v4/src
  • switch to the "order and export" tab, pull up the external jar above the "android dependencies"

enjoy navigating the support library with source!

if you have an "android test project" attached to yourproject, so yourprojecttest might not compiled anymore. in this case, you have to return to "order and export" and pull down the external jar below the "android dependencies" to get things back to normal.


i just want to add yet another method of attaching sources for the support library. it requires adt in version 20 or later. supposedly this method works for all jars for which setting source/javadoc location is disabled by the container. here's what you need to do:

  1. the android-support-v4.jar library lies in the libs directory of your project. in that same directory create a regular java properties file named exactly like the jar in question, but with appended .properties extension. so, for our support library it'll be:

  2. open created properties file and set value of property named src to the location where sources for that library can be found. your file should have one line like:

  3. save the file.

  4. close and re-open your android project.

  5. try browsing to one of the support classes. the source attachment should work now.

worked perfectly in my case.

one thing to note: if src is not an absolute path, it will be resolved starting in the parent directory of the jar file. taking support library as an example - if src=support/src, adt will assume that the class sources are located in libs/support/src.

short description of this feature written by its author can be found here.

if anyone is interested in how exactly this .properties file is processed, i recommend reading patch set #4, esp. changes in eclipse/plugins/ internal/project/ :)


please also see a fine comment by windrider about adding sources properly in a project with multiple referenced libraries.

Related Query

More Query from same tag