Reputation: 5624
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.
Upvotes: 79
Views: 69911
Reputation: 4650
After you have updated the SDK and downloaded Documentations in it:
ext-jars
.Move android-support-v4.jar
to ext-jars
folder.
Add JARs...
then expand the project and select the jar file you already moved to folder ext-jars
.Source attachment
then click on Edit
.External location
then click on External Folder...
[sdk-path]/extras/android/support/v4/src
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/
- 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.
Upvotes: 0
Reputation: 11
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.
Upvotes: 1
Reputation: 2400
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)
Upvotes: 0
Reputation: 16064
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.
Upvotes: 123
Reputation: 1687
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:
../android-support-v4.jar
../android-support-v4-src.jar
It is simple to create the source jar file and attach it:
Upvotes: 2
Reputation: 2612
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:
YourProject/libs/android-support-v4.jar
(I know your project had already referenced to it but don't worry, just add it again).android-sdk/extras/android/support/v4/src
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.
Upvotes: 83
Reputation: 2218
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)
C:/Users/thupten/adt-bundle-windows-x86_64-20130514/sdk/extras/android/support/v4/src
I used the android website doc for java doc location
http://developer.android.com/reference/android/support/v4/app/package-summary.html
Upvotes: 0
Reputation: 3889
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.
Upvotes: 16
Reputation: 2458
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.
Upvotes: 66