How to connect the source of the Android support library in Eclipse?

Having source code connected to external libraries is amazing. Where can I find the source code for the v4 support package? Preferably, it would be a zip file that could be easily linked to android-support-v4.jar in Eclipse.

+78
android eclipse zip android-support-library
Dec 17 2018-11-11T00:
source share
9 answers

After downloading the support package from the Android SDK Manager, you can find the source code of the support package in the <android-sdks> / extras / android / support / v4 / src folder.

+65
Dec 20 '11 at 17:18
source share

I just want to add another way to connect sources for the support library. It requires ADT in version 20 or later. Presumably, this method works for all JARs for which the source / javadoc location setting is disabled by the container. Here is what you need to do:

  • The android-support-v4.jar is located in the libs directory of your project. In the same directory, create a regular Java properties file, named the same as the JAR, but with the extension .properties added. So, for our support library this will be:
    android-support-v4.jar.properties .

  • Open the created properties file and set the value of the property with the name src in the place where the sources for this library can be found. Your file should have one line:

     src=c:/apps/adt-bundle-windows-64bit/sdk/extras/android/support/v4/src 
  • Save the file.

  • Close and reopen the android project.

  • Try moving to one of the support classes. Now the source application should work.

Works great in my case.

It should be noted: if src not an absolute path, it will be resolved starting from the parent directory of the JAR file. Take the support library as an example - if src=support/src , ADT will assume that the class sources are located in libs/support/src .

A brief description of this feature, written by its author, can be found here .

If anyone is interested in exactly how this .properties file is handled, I recommend reading patch set # 4, esp. changes to eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/ internal/project/LibraryClasspathContainerInitializer.java :)

Edit

Also, take a look at WindRider’s excellent commentary on properly adding sources to a project with multiple reference libraries.

+121
Dec 19 '12 at 23:33
source share

Here's a solution for attache support library source in Eclipse Juno

I assume that your project already has android-support-v4.jar in your "build path" in the "Android Dependencies" section, but you cannot attach a source directory to it. ("Source of attachment" said "Not mutable"). Decision:

  • Go to Customize Build Path
  • Add external JARs> YourProject/libs/android-support-v4.jar (I know your project already referenced it, but don’t worry, just add it again).
  • Expand the jar and attach the source to the external jar: android-sdk/extras/android/support/v4/src
  • Go to the "Order and Export" tab, pull the external jar over the "Android Dependencies"

Enjoy the support library navigation through the source!

if you have an “Android Test Project” attached to YourProject , so YourProjectTest no longer compiles. In this case, you need to return to "Order and Export" and pull out the external bank under the "Android Dependencies" in order to return it to its normal state.

+83
Nov 07 '12 at 12:30
source share

Referring to the accepted answer, you can also directly connect a source from a directory without creating a .jar file. On the Java build / library tab / path, expand the support node android-support-v4.jar, highlight "Source Attachment", click "Change ...", "External Folder ...", then specify (android-sdk) \ extras \ Android \ support \ v4.

This has been tested using eclipse indigo.

From the comments:

The problem of not being able to add a source to the support library seems to occur if your support library is in the Android Dependencies folder of your project. The workaround from the same tab "Java build path / libraries" allows you to click "Add External JAR ..." and find the .jar file in your path (android-sdk) \ extras \ android \ support \ v4. It will then appear in your project setup in the new "Linked Libraries" folder.

+16
Feb 18 '12 at 6:30
source share

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

For example:

../android-support-v4.jar
../Android-support-v4-src.jar

Just create the jar source file and attach it:

  • cd to path_to_android_sdk / extras / android / compatible / v4 /
  • Use your favorite email program, such as 7-zip, to create a zip file and name it android-support-v4-src.jar. The first folder in the bank should be / scr.
  • Copy the file to your project, in this example it is in the same folder as jar.
  • In Eclipse, attach the source jar in the project properties.
+2
Jun 28 '13 at 15:17
source share

I simply delete the automatically generated file, and then manually add it as reference libraries.

First open the class, the IDE will ask you to change the attached source.

+1
Aug 13 '14 at 3:35
source share

The process of attaching src and doc from the build path works for some, and it is not for some (for example, for me). some key things to keep in mind

  • Make sure you are in Package Explorer and not Project Navigator .

  • If you placed your android-support-v4.jar folder in the libs folder in your project. big.

  • Right-click on the bank, select "Build Path" .. "Add to Path". (If "Add to Path" is not displayed and then already added, you will see the configure path.)

  • As a result of step 3, a new folder named Linked Libraries appears in the package explorer tree. Open this tree, find android-support-v4.jar support there. Right-click on this jar in the Linked libraries properties. Then install the Java Source Attachment and Javadoc Location.

  • You are done.

The path to my original Java application (its external location)

C: / Users / Thuptno / ADT-pack window-x86_64-20130514 / SDK / add-on / Android / support / v4 / DSI

I used the android site to host in a java document

http://developer.android.com/reference/android/support/v4/app/package-summary.html

0
May 20 '13 at 17:08
source share

I found this for me:

For the main lib library: android.jar:

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

To support lib: android-support-v4.jar: (before that, we need to add android-support-v4.jar as an external jar (Project Properties → Java Build Path → Libraries, then pull this library to Tab 'Order and Export before private Android libraries)):

src: sdk / extras / android / support / v4 / src / java doc: http://developer.android.com/reference/android/support/v4/app/package-summary.html (not sure)

0
Feb 12 '14 at 11:34
source share

After updating the SDK and loading the Documentation in it:

  • Import a support library project into a batch explorer.
  • Create a folder in the library and name it something like ext-jars .
  • Move android-support-v4.jar to the ext-jars folder.

    enter image description here

  • Right-click the project and select Properties.
  • Click "Java Build Path" on the left menu, then select the "Libraries" tab.
  • Click Add JARs... , then expand the project and select the jar file that you have already moved to the ext-jars folder.

enter image description here

  • Expand the added jar and select Source attachment , then click Edit .
  • Select External location , then click External Folder...
  • Select the source folder for v4 support, which is located in [sdk-path]/extras/android/support/v4/src

enter image description here

  • Select a Javadoc location click Edit , then select the Javadoc URL , then click Browse... and select the javadoc location for v4 support, which is located in [sdk-path]/docs/reference/

enter image description here - Select the Order and Export tab and check only android-support-v4.jar .

I suggest you also clean up the project and reopen Eclipse.

0
Sep 19 '16 at 7:25
source share



All Articles