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
make sure you are in package explorer, not project navigator.
if you have put your android-support-v4.jar in libs folder under your project. great.
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..)
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.
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: http://developer.android.com/reference/android/support/v4/app/package-summary.html (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
- 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
- expand the added jar and select
source attachmentthen click on
external locationthen click on
- choose the source folder for the support v4 which is located in
javadoc locationclick on
javadoc urlthen click on
browse...and choose the javadoc location for support v4 which is located in
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.
it is simple to create the source jar file and attach it:
- cd to path_to_android_sdk/extras/android/compatibility/v4/
- 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.
- copy the file to your project, in this example it is in the same folder as the code jar.
- 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:
- 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
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:
android-support-v4.jarlibrary lies in the
libsdirectory of your project. in that same directory create a regular java properties file named exactly like the jar in question, but with appended
.propertiesextension. so, for our support library it'll be:
open created properties file and set value of property named
srcto the location where sources for that library can be found. your file should have one line like:
save the file.
close and re-open your android project.
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
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/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/ internal/project/libraryclasspathcontainerinitializer.java :)
please also see a fine comment by windrider about adding sources properly in a project with multiple referenced libraries.
- How do I attach the Android Support Library source in Eclipse?
- Eclipse -> Android Studio migration: how to include v4 support library (also including the ant build script)
- How to attach source code to Support Library in Eclipse
- How to attach Android Source to Eclipse
- How to attach source to the libraries on Eclipse CDT
- How to use the same source from PhoneGap Build and PhoneGap Android project in Eclipse
- How to attach the source to the jar in the Gradle Eclipse Project when the source attachment is not modifiable?
- How to import Eclipse project with source control to Android Studio without changing the directory structure to the Gradle one?
- How to update to the latest version of Android Support Library in Eclipse?
- How to force Eclipse project to use an older version of the support library
- How to bundle the v7-appcompat support library into an application source code?
- How to modify source android when I attach the source
- How to import android support library in eclipse on mac?
- How to get elements from Android Design Support Library into the GUI builder in Eclipse?
- How to add an android library to an eclipse project without checking it out in the workspace?
- How to output messages to the Eclipse console when developing for Android
- How to attach source or JavaDoc in eclipse for any jar file e.g. JavaFX?
- Attach the Source in Eclipse of a jar
- How to attach back the Android emulator to ADB?
- Using the Android SDK on a Mac, Eclipse is really slow. How can I speed it up?
- How to attach Android source to Eclipse?
- Android actionbar how to add supporting library v7 appcompat for Eclipse
- How to remove native support from an Android Project in eclipse because eclipse is showing errors in jni?
- Where can I find the source code for the Android Development Tools (ADT) plugin for the Eclipse IDE?
- How to get the Android API documentation in Eclipse
- Eclipse Android project, how to reference library within workspace?
- How to obfuscate an Android library (.jar file) using Proguard in Eclipse
- How do you compile an Android project into an .apk file in Eclipse without launching the emulator?
- How to use Legacy Apache in Eclipse in order to support Android M
- How to get the graphical layout Window back in Eclipse for Android Application Design?
More Query from same tag
- Where I can find System.out.println output when running Selenium in Eclipse?
- Unable to setup Eclipse for Android Development
- Eclipse shows nasty white cross in red circle with no message
- Tomcat 9.0.52 crashes with "java.util.zip.ZipException: invalid LOC header (bad signature)" when started in debug mode - any work-around?
- Eclipse does not run Jboss standalone.conf
- "The package java.sql is not accessible." in eclipse
- MY app is being force Closed on emulator. its based on samlpe calculaor code found on a russian website on google
- including required jars in project
- JBoss EAP 6.3.0 errors in Eclipse Servers View
- "Cannot be resolved to a type" when attempting to use Scanner
- Eclipse 'Open PHP Type' dialog box
- Eclipse E4: "IWorkbenchWindow" not getting injected in ProgressRegion
- Retrieving a java element's javadoc url in Eclipse
- Eclipse device chooser
- Eclipse - passing VM parameter to every test in the project
- Scanner stops reading randomly when ran from exported .jar but not when ran from Eclipse
- Unable to compile Android Source code (cloned from Git)
- Android Eclipse AsyncTask - but result is empty - can someone have a look
- Get FindBugs to report errors separately
- Eclipse android ADT installation issue
- Egit error when saving file
- Open "gradle" project
- How do i fix this mvn install error? Failed to execute rpm-maven-plugin
- Parsing a webpage in Eclipse using Jsoup
- What are the settings to modify the default getter and setter methods provided by Eclipse?
- Eclipse c++ library not found in debug mode but found in release mode
- Eclipse Plugins disappeared
- Adding Help Contents, Search Help using Command Framework
- debugging infrasturcture for RAP application
- Presigned Amazon S3 URLs created by eclipse not working