Having the source code attached to external libraries is awesome. Where do I find the source code for the v4 support package? Preferably, it would be a zip file which could be easily attached to the android-support-v4.jar
in Eclipse.
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:
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:
android-support-v4.jar.properties
.
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:
src=c:/apps/adt-bundle-windows-64bit/sdk/extras/android/support/v4/src
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 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/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/ internal/project/LibraryClasspathContainerInitializer.java
:)
Edit
Please also see a fine comment by WindRider about adding sources properly in a project with multiple referenced libraries.