45

I've previously had success attaching the Android Source to Eclipse by following Finn Johnsen's instructions here.

However this approach seems to have stopped working:

samuel-josephs-computer-4:android-sources samueljoseph$ git checkout origin/froyo-release
Previous HEAD position was 1de4a2c... am 62619392: Merge "Fix leak when keylock is recreated."
HEAD is now at adba66b... This class no longer exists.

There was a more recent blog here which had some pre-organized source for Eclair, but nothing since.

There are also some StackOverflow posts from 2008 (older than both the above), e.g. https://stackoverflow.com/questions/3182904/attaching-java-source-to-android-projects-in-eclipse.

What is the current guidance for accomplishing this?

asked Mar 8, 2011 at 14:14
1
  • 1
    There's now an easier way to attach Android platform sources. See this answer. Commented Mar 10, 2012 at 19:23

6 Answers 6

41

There is a updated guide. So, you don't need to install an eclipse plugin for this.

Here is the link

Snip from above Link:

follow below steps if you already have downloaded Android sources

  1. Head into eclipse, and press F3 over some android source you're missing, like Activity. And get this pesky window, which we all hate:

  2. Click Attach Source, choose External Folder, and choose the core/java in the base folder.

answered Apr 16, 2011 at 0:25
Sign up to request clarification or add additional context in comments.

4 Comments

This guide explains a simple way to attach the sources, no plugins required. Great method
This should be the first answer :)
An addendum for the android support libraries: E.g., the android-support-v4.jar needs to be in "Referenced Libraries", not just the "Android Private Libraries." To get it there, I went to the Order and Export Tab of Eclipse's Java Build Path Screen and moved android-support-v4.jar higher up in the list. Otherwise the support jar was stuck only in the Android Private Libraries folder, and not also in the Reference Libraries folder, which for some reason is what you actually need before it will let you attach source.
@Merk Alternatively, include a android-support-v4.jar.properties file in the same project folder as android-support-v4.jar (usually libs) and containing the line src=<absolute_path_to_source>. I'm not sure if Eclipse will copy the properties file along with the support library for new projects if you store it alongside the original support library in the sdk folders, though.
32

There is an Eclipse plugin called Android Sources that installs the sources up through Gingerbread. I haven't tried it recently.

answered Mar 8, 2011 at 15:03

4 Comments

that looks awesome. However I got an error when trying to install. I just upgraded to Android 3.0 and the latest ADT, so perhaps that's an issue. I filed an issue on the project site
Had a response! Eclipse GEF framework was missing. I think I had their update site disabled for some reason, which was preventing the correct install; and now I can see the Android source yay!
Unfortunately it does not support API about 9
The plugin supports source up through API level 14 (Android 4.0.1) and includes an easy-to-use update site.
31

For Android 4+ here's a tutorial for attaching sources to eclipse.

EDIT:

  1. First download the source and javadoc from sdk manager.Download these.
  2. Goto Your_Project>>Android XXX, Right-Click on android.jar and select Properties.

  3. Point the sources path as Java Source Attachment>>Location Path by clicking on External Folderenter image description here

  4. Point the reference path as Javadoc Location>>Javadoc Location Path by clicking on Browseenter image description here

Now you can browse sources like this: enter image description here

answered Jul 21, 2013 at 20:10

1 Comment

Agreed, no need to use other plugins on eclipse.
12

Here's a tutorial:

  1. Make sure you have installed/downloaded the Android source for the appropriate Android SDK API version.

    1.1 Check the API version you have specified in Eclipse for Android/Project Build target:

    project Properties/Android

  2. Open project Properties/Java Build Path and click the "Link Source..." button on the Source tab:

    project Properties/Java Build Path

  3. Point to where you have installed the Android SDK, expand the "sources" folder, select the appropriate source API version (and click "OK"):

    select source API version

  4. Next...:

    Link Source

  5. Important step is to exclude the whole linked source from building. Otherwise we could have some duplicate source errors plus who wants to build the whole Android source when we have jars already! So, click "Add...", type in *, click "OK" (and then "Finish"):

    exclude everything

  6. Verify everything is configured correctly:

    configured

Desired result -- linked platform source w/o side effects:

source

I hope this helped :)

answered Feb 6, 2014 at 20:14

2 Comments

Doesn't work for this class BaseDexClassLoader i'm using Android 4.4 wear!
this is the package dalvik.system.BaseDexClassLoader can't find it in the source!
8

The best way is as below.

  1. Update Android SDK Manager, including source of the version you need.

  2. click on Any class like activity, if source is properly attached, it will open the Activity class.

  3. If it is not opening up, then click on the attach source and can give source path as above.

  4. Source path will be like android-sdk-windows\sources\android-17

This will help you to add source for android SDK

answered Oct 30, 2013 at 6:43

Comments

1

You can do it this way .... hover or copy paste any class_name which is provided from android , just press F3 you will find a Attach_a_source tag there , click in it & here browse your android-sdk folder and from it just pick source folder because inside it , every android files resides .

Lance Roberts
22.9k32 gold badges115 silver badges132 bronze badges
answered Mar 19, 2013 at 7:02

2 Comments

Lone link is considered a poor answer (see faq) since it is meaningless by itself and target resource is not guaranteed to be alive in the future. It would be preferable to include the essential parts of the answer here, and provide the link for reference.
Next time , i will take care of it .

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.