Attach Android source code to Eclipse IDE

By default, Android SDK or Eclipse ADT plugin are not bundle with any Android’s source code for debugging. In Eclipse IDE, step into any Android class will prompt no source code attach, see following screen :

android source code not found in Eclipse

Solution

According to this official Android source code article, it’s shocked that we need to use “repo” to download and then build the entire source code to get the source for “android.jar“.

If you think above is too much works, alternatively, you can install the Eclipse plugin called “Android Source” to get source for “android.jar“. Read this article “Additional Eclipse plugins for Android“.

After installed the “Android source” plugin, suppose the existing projects as well as new created projects which is targeted for Android will have attached the source jar automatically. However, my existing Android project still didn’t attach to the correct source, i have to attach it manually.

Locate “Android Source” plugin folder, it should be in following directory :


ECLIPSE_PATH\plugins\com.android.ide.eclipse.source_MAY_BE_VARY

Folders :

android source folders
  • 14 – Android 4.0.1
  • 10 – Android 2.3.4
  • 9 – Android 2.3
  • 8 – Android 2.2
  • 7 – Android 2.1
  • 6 – Android 2.0.1
  • 4 – Android 1.6
  • 3 – Android 1.5

Each folder contain a “sources.zip“, which target to specific Android version. For example, if you develop Android 2.3, then get the “sources.zip” from folder “10“, and attach it to the Eclipse IDE manually.

Step into Android class again, source code is display.

attach android source code to eclipse ide

References

  1. Additional Eclipse plugins for Android
  2. Android Open Source Project

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

Leave a Reply

avatar
newest oldest most voted
Nishant
Guest
Nishant

Useless

crusty coder
Guest
crusty coder
This blog post is about 3 years old, and although this post is helpful, there has been alot of development by Google since then. I would recommend developers try the Android ADT rather than shoe-horn an Android Plugin into Eclipse. The ADT has matured and is a fully integrated standalone Eclipse based environment. The reason I recommend using the ADT is that it also includes an “Android SDK manager” that can do exactly what is being written about above and does most of the heavy lifting for you. You can see exactly what you need to do by reading this… Read more »
sumeet guha
Guest
sumeet guha

Not working in my case, I don’t think it so useful.
Please try to right click on Android.jar file of your project, and then click on properties options, and then select “Java source code” option, and then select android source code folder from your system by click on external locations.

In this way, you can easily attach android source code to your android project.
Problem in this approach in that, you need to do same thing for each project in eclipse.

Thanks,
Sumeet Guha.

siddhu
Guest
siddhu

nice tutorial

preksha
Guest
preksha

i like this website very much for android tutorial.I want bluetooth and music player tutorial also.

Android Guru
Guest
Android Guru

How to check whether Wi-Fi internet access is active or not in a device. Take a look at the post:
http://android.programmerguru.com/android-check-wifi-internet-connection/

ram
Guest
ram

Hi Mkyong,

I followed above tutorial but i am unable to install the plugin. I get this error message

an error occurred while collecting items to be installed session context was:(profile=profile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).

It would be greatful if you could tell me the solution for this problem

pavan
Guest
pavan

Iam not finding any source code of ur project…

pavan
Guest
pavan

Hello ,where is source code ….
I didn’t find any source code of above project..

abc
Guest
abc

put mp3 player’s source code

trackback
Debugging into Android source : Android Community - For Application Development
trackback
Android Class Tree : Android Community - For Application Development

[…] you can download the android source and integrate it with eclipse […]

trackback
Microcontroller Central - Aubrey Kagan - Android for Embedded: You Must Be Joking

[…] reading this description as to how to remedy the problem, or even this one. Get any sense out of them? Technically, what you're supposed to do is download all the source […]

sv
Guest
sv

No source code for API level 15 and above.

m
Guest
m

Thank you, very good.

sahil
Guest
sahil

Sir
plz post smthg on debugging using Logcat and breakpoints ,handling “…stopped working unexpectedly” error
Thanks for other posts!!!